Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Getting maximized dialogs normal size?



  • I want to save the size of a dialog so I can restore it on subsequent runs. But when the dialog is maximized I want to save it's unmaximized size and then a flag stating that it's maximized so that if the user clicks the restore button it returns to its smaller state.

    I tried calling showNormal() in the accept/reject handlers before saving the size, but when I do that width()/height() still return the maximized size values. I even tried adding a sleep, thinking maybe they needed a second to catch up, but still no. If I restore the dialog manually and then close I get the proper values. But restoring it to normal from code using showNormal or setWindowState both still result in the maximized size being reported.

    Is there any way to get the "normal" size from a dialog when it's maximized? Or some way for me to call showNormal() and then wait in a non-blocking way until the dialog is resized and the values are correct?



  • Of course I figured this out just a few minutes after posting, sorry for wasting your time.

    Anyone who's interested there is a function in the dialog/widget class called normalGeometry() which holds the unmaximized size of the window.


Log in to reply