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

Add an option to use restoreGeometry() without screen width difference checks (not always working otherwise)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.2
    • None
    • Windows 7 64 bit, Windows 10 64 bit.
    • Windows

    Description

      An ability to disable checks of screen width difference between current and saved into configuration would be useful because otherwise restoreGeometry simply returns false, if, for example, current screen width = 3440 px and the saved one is 1920 px. The widget is still looking good if bypass the checks and allow scaling to the whole screen in maximized mode.

      These checks would be good to bypass - say, adding some flag to the restoreGeometry() function: 

      restoreGeometry(const QByteArray &geometry, bool allowBigScaling = false);
      

       Currently these checks force the function restoreGeometry() to return false (starting from line 7261 in qtbase\src\widgets\kernel\qwidget.cpp in my version): 

      const qreal screenWidthF = qreal(QDesktopWidgetPrivate::screenGeometry(restoredScreenNumber).width());
          // 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;
          } else {
              // Saved by Qt 5.3 and earlier, try to prevent too large windows
              // unless the size will be adapted by maximized or fullscreen.
              if (!maximized && !fullScreen && qreal(restoredFrameGeometry.width()) / screenWidthF > 1.5)
                  return false;
          }
      

      With my current Qt version (5.15.2) I have to deserialize QByteArray using information from the Qt sources, set restoredScreenWidth and restoredFrameGeometry.width() to the current screen width and serialize back before sending an array into restoreGeometry() func.

       

      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
            trig-ger Andrey M. Tokarev
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes