access on main window from anothe window (e.g Dialog)
Good evening everybody...
My Question as simple as in the title !!
I try to write in line edit witch is in the main window,while my button exist on another window (dialog window).
When I try to make that, I put in the event handler the dialog button:
Code:
MainWindow::ui->lineEdit_1->text() = :ui->lineEdit_2->text() ;
while :lineEdit_1 is in the main window and :lineEdit_2 is in the dialoge.
but the honorable compiler tell me that :
1) Object missing in reference to 'MainWindow::ui' .............in mainwindow.h
2)from this location .............in dialog.cpp
I have search about this, but I didn't understand the meant.Let alone most of what I found was about multi threading not about forms.
Thank you.
Re: access on main window from anothe window (e.g Dialog)
Use signals and slots to update your lineEdit
LE: also you will need setText(QString); (or &) because the text() returns the QString, so you cant do assignment to lineedit.text().
Re: access on main window from anothe window (e.g Dialog)
Zlatomir .Sorry for the delay.
Thank you for your replay.
I think that your suggestion is more professional ,but I have found another simple solution by make function in class dialog.This functoin have to return the content of lineEdit.
e.g
Code:
QString dialog
::getLineEditText() const {
return ui->lineEdit->text();
}
Then call it like after execute the dialog
Code:
ui->lineEdit->setText(x.getLineEditText());
THANK YOU FOR YOUR INTEREST.