Search code examples
qttouchscreenqdialogqeventloop

QDialog popping up another QDialog


I have a subclassed QDialog containing a bunch of subclassed QSpinBox's. When clicking a spinbox, a keypad (another QDialog) where you can use pushbuttons to enter digits. Both QDialog's are activated by calling QDialog::exec();

However, when opening this 2nd QDialog, the first one closes down. I've stepped through it and noticed the 1st QDialog doesn't end yet. QDialog 1 sends out "QDialog::Rejected" AFTER I finish QDialog 2. What I'd want is the QDialog 1 not to end at all, it needs to update the spinbox with the entered value and open up more QDialog's for other spinbox's the user wants to edit later on.

I think it has to do with the QDialog 1's eventloop being killed by QDialog 2's eventloop. I've tried using QDialog::show on QDialog 2. The widget pops up for a moment (millisecond) but doesn't stay active. QDialog 1 is immediately closed as well.


Solution

  • QDialog 1 is set to Qt::Popup, QDialog 2 was set to Qt::Dialog by default. A popup closes down on a wide range of events. I've set QDialog 2's flag to Qt::Popup as well, which doesn't seem to close down QDialog 1 anymore.