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

Main window set geometry doesn't always work



  • 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
    the screen.
    What's going on?


  • Lifetime Qt Champion

    Hi,

    How do you save and reload the geometry ?
    When do you do it ?



  • 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.


Log in to reply