PDA

View Full Version : how to program custom Dialogs with return values



momesana
22nd December 2006, 23:58
Hi,
I wonder how to write modal Dialogs executed with QDialog::exec(), that provide a result other than integer values ( which can be easily achieved with QDialog::accept(), QDialog::reject() and QDialog::setResult() ). Since there are Dialogs that return objects like QFonts, QColors etc. all over Qt4, I guess there must be a (simple) mechanism to do that. Any Ideas?

thanx in advance
momesana

jacek
23rd December 2006, 00:14
Since there are Dialogs that return objects like QFonts, QColors etc. all over Qt4
Yes, but they either use static methods or signals.

wysota
23rd December 2006, 00:37
Of course you can always do something like this:


class MyDialog : public QDialog {
public:
// ...
QString myExec(){
if(exec())
return myresult();
else return "";
}
private:
QString myresult() const { return ... }
};

and call it using

MyDialog dlg;
QString r = dlg.myExec();