Reputation: 187
I have a multiple QDialog
windows. All windows are created with exampleWindow->exec()
. This caused only one window is open at the time.
I have to convert these windows to non-modal dialog window
Here sample code example of my project. When the exec() is using the system is going into loop and wait for the user do something on the window.
int result = exampleWindow->exec();
if ( exampleWindow== QDialogButtonBox::Ok )
{
exampleWindow->UpdateCalibrationData(&data);
exampleWindow->UpdateFilterData(&filterData);
SetCalibrationStatusToSuccess();
}
But I want to convert this one to like that:
exampleWindow->show();
// and I need to some loop here for the wait answer of dialog
Upvotes: 1
Views: 11556
Reputation: 601
I did'nt have enough reputation to be able to comment. But if with a QDialog
you can just call myDialog->show()
If you have your dialog as a member variable it can only have 1 open instance of its self. If you want to make something non modal there is a setting or a flag you can set on that dialog.
QDialog::show();
QDialog::setModal();
If you have a look at the documentation. Please could you make your question a little clearer? What is your actual problem? Or is it just preference how you want your QDialog
to be shown. As the post above me shows you can check for signal and slots for if the Dialog has been closed/accepted.
Its better to use
QObject::connect(obj, &Class::signal, obj, &Class::slot)
- this will give compiler errors if the signals and slots cant connect.
Than
connect(obj, SIGNAL(), obj, SLOT())
- where as this will only give you a run time error. But will not crash or output a warning and will just continue.
Upvotes: 3
Reputation: 428
You can create a non-modal dialog with
exampleWindow->show();
After the user closes the dialog, you can get the signal emitted by the dialog:
QObject::connect(&exampleWindow, SIGNAL(accepted()), this, SLOT(doSomething());
and receive the dialog data in that slot function.
Upvotes: 8