[英]access main window from dialog in qt
in the main window their is lineEdit_1 and in the dialog their is lineEdit_2. 在主窗口中,它们是lineEdit_1,在对话框中,它们是lineEdit_2。 once a button is clicked the dialog window will open. 单击按钮后,对话框窗口将打开。 now I need the lineEdit_2 to get the value of lineEdit_1 in the main window. 现在我需要lineEdit_2才能在主窗口中获取lineEdit_1的值。
(the main window class is MainWindow
and dialog window class is dialog
) (主窗口类是MainWindow
而对话框窗口类是dialog
)
I tried to do it like this, but it gives a error error: ISO C++ forbids declaration of 'MainWindow' with no type
我试图这样做,但是它给出了一个错误error: ISO C++ forbids declaration of 'MainWindow' with no type
dialog.h 对话框
MainWindow *main; //declair a pointer to the main window
dialog.cpp dialog.cpp
lineEdit_2->setText(main->lineEdit_1->text());
whats the mistake here. 这是什么错误。
I would be very thankful in any advice. 我会很感激任何建议。 thank you. 谢谢。
void dialog::lineText(QString text){
lineEdit_text = text; //let lineEdit_text be a QString member in your
//dialog class. Pass the text before calling
//setVisible() in the client code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.