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

Initializing visible value affects how setGeometry at Component.onCompleted changes window on screens with different DPI

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.12
    • Fix Version/s: None
    • Environment:
      Left primary screen 2560x1440 100% scale

      Right secondary screen 3840x2160 200% scale
    • Platform/s:
      Windows

      Description

      Users have observed that QML windows receive an incorrect size when using the setGeometry function on the QtQuick window object.

      Qt Support tested with:

      Left primary screen 2560x1440 100% scale

      Right secondary screen 3840x2160 200% scale

      Empty default QtQuick template project with AA_EnableHighDpiScaling enabled.

       

      Following code was added:

      visible: false//or true
      
      Button {
              text: "Fix the size"
              onClicked: {
                  var rect = Qt.rect(2560+100, 100, 200, 200)
                  root.setGeometry(rect)
                  console.log("width",root.width," height",root.height)
              }
          }
      
          Component.onCompleted: {
              //2560 to first screen resolution at Qt support
              var rect = Qt.rect(2560 + 100, 100, 200, 200)
              root.setGeometry(rect)
              root.visible = true
              console.log("width",root.width," height",root.height)
          }
      

      Depending on initializing visible value 5.12.4 and 5.12.6 gave different width/height values on Component.onCompleted root.setGeometry(1stwindow.w+100,100,200,200):

      false, Qt 5.12.4: Size same

      false, Qt 5.12.6: half size

      true, Qt 5.12.4: 4x size

      true, Qt 5.12.6: 2x size

      With the button press the window was set to the 200% screen with given width and height but the scale of the title bar is equal of 100% scaling.

       

      Example project attached.

       

        Attachments

        1. INC-1287934.zip
          6 kB
        2. qtbug80246.zip
          6 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            qt.team.quick.subscriptions Qt Quick and Widgets Team
            Reporter:
            tero.pelkonen Tero Pelkonen
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes