View Full Version : passing data when closing a dialog
jimiq
4th November 2009, 14:32
I have a main dialog which invokes another dialog (using .exec()) to get the user to enter a string when the close button is pressed I want to pass that string back to the main dialog. How do I do this? I tried emiting a signal but this crashes the application.
Lykurg
4th November 2009, 14:39
after executing the dialog, get the value of your lineedit through a self defined getter method. E.g.:
MyDialog dlg;
switch(dlg.exec())
{
//...
dlg.getMyLineEditValue();
}
jano_alex_es
4th November 2009, 15:10
using references is another way to do it.
jimiq
4th November 2009, 15:14
using references is another way to do it.
Do you have an example of this?
jano_alex_es
4th November 2009, 16:48
in the constructor of teh dialog, just send a variable by reference.
for instance:
class CmyDialog : public QDialog
{
public:
CmyDialog (QString& myString, QWidget *parent = 0);
~CmyDialog ();
//change myString in your code
}
QString strIwantMyDataBack;
CmyDialog _MyDialog(strIwantMyDataBack, this);
_MyDialog.exec();
For your interest (http://en.wikipedia.org/wiki/Reference_%28C%2B%2B%29)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.