Reputation: 17253
I currently have a formA that requests input from a user using another form that inherits from QDialog. The form is prompted using QDialog::exec. Now the problem is that there are going to be multiple instances of formA thus whenever any of formA opens up another form as a dialog the entire application blocks.Currently I have something like this
if(formUserInputRequired->exec()==1) //Block until the user selects from a form
{
}
Is there a way to make QDialog::exec not block the entire application I just want it to block only the instance of the form it was called on or something like that but definitely not the entire application?
Update: I do not need a blocking window. However I would like for a way to know when the user is done with the input in another form so that the original form can process that data
Upvotes: 4
Views: 10761
Reputation: 112
You can use show() instead, and then to grab dialog result you connect the signal of accept to a slot of your formA to treat it, just like:
connect(formUserInputRequired, SIGNAL(accept()), this, SLOT(acceptClicked());
formUserInputRequired->show();
Upvotes: 2
Reputation: 9014
You can use show()
method instead of exec()
, because exec
method has it's own event loop.
Upvotes: 0
Reputation: 28728
Call the setWindowModality
method on the dialog with Qt::WindowModal
as the argument.
Qt::NonModal 0 The window is not modal and does not block input to other windows.
Qt::WindowModal 1 The window is modal to a single window hierarchy and blocks input to its parent window, all grandparent windows, and all siblings of its parent and grandparent windows.
Qt::ApplicationModal 2 The window is modal to the application and blocks input to all windows.
Upvotes: 8
Reputation: 48216
set the modality of the dialog to Qt::WindowModal
(the default of QDialog is Qt::ApplicationModal
)
Upvotes: 1