Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-86087

QWidget::restoreGeometry() breaks when monitors are added/removed

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.0
    • Widgets: Main Window
    • None
    • Arch Linux, Qt 5.15.0
    • Linux/X11

    Description

      If a second monitor is added or removed before starting a Qt application (e.g. when a laptop is docked or undocked), QWidget::restoreGeometry() no longer restores the size of the application on startup. The behavior is reproducible with Qt 5 applications such as KeePassXC and Audacious.

      I believe the culprit is this code:

          // Sanity check bailing out when large variations of screen sizes occur due to
          // high DPI scaling or different levels of DPI awareness.
          if (restoredScreenWidth) {
              const qreal factor = qreal(restoredScreenWidth) / screenWidthF;
              if (factor < 0.8 || factor > 1.25)
                  return false;
      

      Note that restoredScreenWidth is actually the total desktop width (all monitors). It does not seem like a good idea to assume that DPI has changed every time the desktop width changes, since the width can change for other reasons as well.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            john.lindgren@aol.com John Lindgren
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes