[英]access main window from dialog in qt
在主窗口中,它們是lineEdit_1,在對話框中,它們是lineEdit_2。 單擊按鈕后,對話框窗口將打開。 現在我需要lineEdit_2才能在主窗口中獲取lineEdit_1的值。
(主窗口類是MainWindow
而對話框窗口類是dialog
)
我試圖這樣做,但是它給出了一個錯誤error: ISO C++ forbids declaration of 'MainWindow' with no type
對話框
MainWindow *main; //declair a pointer to the main window
dialog.cpp
lineEdit_2->setText(main->lineEdit_1->text());
這是什么錯誤。
我會很感激任何建議。 謝謝。
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.