views:

318

answers:

2

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.

+1  A: 

The way you've verbally described the code, you shouldn't be seeing the problem you describe. Without seeing your actual code, I couldn't hazard a guess as to what is causing the problem. However, I can say with certainty I've run exec() on dialog A, then inside that run exec() on dialog B (from a button), and had dialog A stay available when dialog B exits.

Caleb Huitt - cjhuitt
Thanks, the part about the eventloops was indeed a dead end.
Pieter
+1  A: 

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.

Pieter