PDA

View Full Version : What is the best way to popup an option dialog before the program starts?



Dauntless
22nd February 2007, 04:32
I would like to know what's the best way to popup a dialog, from which the user could select an option before the main window of the program starts.
I can’t just show both, because the MainWindow needs to know the option selected in the first dialog to work properly, so I need to freeze somehow the process until the user selected the option in the first dialog.
I was wondering what's the best approach to make this work? Use qthreads, qtimer, use some QCoreApplication commands or maybe there is an ever better way.

I’m a novice and I don’t know yet the proper way to do it, thank you if you can help me.

sarode
22nd February 2007, 07:02
Hello,

I know this well in Qt 3.3.x. You can use this example application under Qt 3.3.3 ..

/usr/share/doc/qt-devel-3.3.3/examples/i18n/

You may get some help!

Regards,

sunil.thaha
22nd February 2007, 08:58
You could do something like this



int main( ... ) {
QApplication app( ... );

OptionsDialog dlg;
[...]
if( dlg.exec() != QDailog::Accepted )
return 0; // Terminate if Options not set or may be set defaults

// Get the Options, could use a structure for that
Options options = dlg.options();
MainWindow w;
w.setOptions( options );
w.show();
app.exec();
}


you can also try to create the Options Dialog dynamically

Dauntless
22nd February 2007, 14:10
Great answer sunil.thaha, that's exactly what I wanted. I knew there must be a better way to do this, thank you for giving me such a smart solution.

Thanks sarode for the reference, it is related to what I needed, but I am glad I found an even cleaner way to do it thanks to sunil.thaha comment.