Close Dialog in showEvent
If I do the following
Code:
void DialogExample
::showEvent ( QShowEvent * event
) {
close();
}
The Dialog is not closed. Instead the Dialog Interface is frozen on the screen and can not be closed with the mouse anymore.
Why ? What is the solution?
The complete problem is the following
Code:
void DialogAgilentPowerSensor
::showEvent ( QShowEvent * event
) {
if (!m_isAgilentPowerSensorLoaded)
{
"Could not connect to Agilent Power Sensor",
close();
}
}
Thus, in the constructor a class is loaded and after the construction the dialog shall be closes if the device could not be loaded.
Matthias
Re: Close Dialog in showEvent
Why not check if the sensor is available before calling show() instead of doing that in showEvent()?
Re: Close Dialog in showEvent
Quote:
Originally Posted by
wysota
Why not check if the sensor is available before calling show() instead of doing that in showEvent()?
That can of course be done. It requires however that the whole code for loading the external device is also moved outside of the dialog. So in any case this problem is solvable. My question however would be why this approach is not working.
Matthias
Re: Close Dialog in showEvent
Closing the dialog from within showEvent might not be... safe. It's like you'd try to delete "this" from the constructor... Showing the messagebox there might also be causing problems. You might look into Qt's sources to see how ShowEvent is handled.