PDA

View Full Version : Get data from a QLineEdit, inside a Qt Designer for class



aguleo
26th January 2013, 15:47
I have a QMainWindow (w) thal creates an instance of a myDialog at a certain moment.
In the action used to manipulate this case i have:

myDialog dialog;
dialog.exec();
info = dialog.?????????

I suppose that a get function is not needed to fetch some text from a lineEdit in the ui!
This is a Qt Designer Form Class (myDialog.h + myDialog.cpp + myDialog.ui).
How do i get there?

Santosh Reddy
26th January 2013, 15:58
I suppose that a get function is not needed to fetch some text from a lineEdit in the ui!
It is better to have a function to return the text of the line edit.

or

You could also make the ui variable public and but is very good solution.

info = dialog.ui->lineEdit->text();

aguleo
26th January 2013, 16:09
I see.
But the ui is created in the private section ... so i better leave it there :)
I'm going for the getset style.

anda_skoa
27th January 2013, 13:28
You could also make the ui variable public and but is very good solution.


Indeed!
It also requires that the code using myDialog needs to have the include for the generated header that declares the ui object. Thus forcing an unnecessary rebuild of the using code whenever the UI file changes.

Cheers,
_