Dargon Dargon - 1 year ago 128
C++ Question

QT - Dialog(modal) with sub functions

firstly I have to apologize for my bad English, I'm still learning the language ;)

Now, my Problem:

I've created a Dialog named form.ui, I've created it via pointer in the main Header:

QDialog *newform;
Ui::Form Form;

private slots:
void slotShowEntry();
void newEntry();

Then I called it in the main Program:

void SoftwareV::slotNewEntry()
newform =new QDialog;

connect(Form.buttonBox_ok_ab, SIGNAL(accepted()), newform, SLOT(newEntry()));

Now, I want to get the information the user has written/given into the Dialog with the Subfunction called newEntry(),eg I want to get text from the QLineEdit, but I have no idea how I can connect the Dialog with the subfunction.

I hope somebody can help me with this Problem! thank you!

Answer Source

There's not quite enough information in your code to be exact, but I think what you're looking for is something like this in your newEntry method:

QString user_text = Form.someLineEdit->text ();

Instead of "someLineEdit", the name of the control is the name you gave it in Qt Designer when you created the form. What you do with the user_text result is up to you. Each control in the form has a unique name, and how you get data out of the control depends on the type of control (QCheckBox, QComboBox, QLineEdit, etc.). Each of those controls has functions for setting and retrieving data. You can look them up in Qt Assistant for complete details.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download