Modal dialog only modal to base window?
Hello!
I'm trying to create an multiple window application and have problems with the
modal dialogs.
My basic code is the following:
Code:
MainWindow *mainWin = new MainWindow;
mainWin->show();
In the MainWindow class I have the following function:
Code:
void MainWindow::newWindow()
{
MainWindow *mainWin = new MainWindow;
mainWin->show();
}
This works fine.
But, the modal dialogs executed from the MainWindow class (for adding/editing data)
block any showed windows. I expected the dialogs only to block the (base) main window
it was called from, but instead it blocked any other main windows too.
Is this so by Qt's design or is there any way to change this behavior?
Regards
Sven
Re: Modal dialog only modal to base window?
Whenever you create a QDialog, call setModality(Qt::WindowModal) to override the default behavior (Qt::ApplicationModal) which blocks all windows in the application.
[SOLVED] Re: Modal dialog only modal to base window?
Thank you for the hint!
I did' see this method.
To be correct, it is this function:
Code:
setWindowModality(Qt::WindowModal);
Regards
Sven
Re: [SOLVED] Re: Modal dialog only modal to base window?
Oops, my bad. I indeed meant setWindowModality().