Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Main window set geometry doesn't always work
Qt 6.12 LTS is out! See what's new in the release blog

Main window set geometry doesn't always work

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 749 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dabble53
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #3

        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.

        The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt
        • Unsolved