Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QDialog::exec() blocks the application

Tags:

c++

qt

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

like image 684
MistyD Avatar asked Dec 21 '22 00:12

MistyD


1 Answers

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.

Source

like image 55
kol Avatar answered Jan 05 '23 21:01

kol