Main window set geometry doesn't always work
dabble53 last edited by
I have a Qt desktop app (Qt5, MSVC17, x64) that saves the main window geometry on exit, and loads back that geometry on startup.
On startup, after the UI has been initialized (ui->setupUI(this)) I read the geometry from the saved settings and call setGeometry(geomrect)
I verify with qDebug() output that the saved/read geometry values are correct. The problem
is that sometimes the main window is positioned way to the left of where the geometry says
it should be positioned. It never moves vertically, just horizontally. In my paintEvent method
I can see that the main window geometry has indeed been shifted left, usually by a significant amount. The result is that sometimes the window is not actually visible on
What's going on?
How do you save and reload the geometry ?
When do you do it ?
Kent-Dorfman last edited by
If it was non-windoze I would suggest that main window location is treated by many window managers as a "hint" and not a "rule". Not sure what the placement rules are in the MS world.