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

Unable to properly position window with multiple screens using scaling

    XMLWordPrintable

Details

    • Windows

    Description

      Given a Windows system with two monitors, the second one right of the first, scaling set to something > 100%.  Given a QML app with corresponding QT_SCALE_FACTOR set and a Window which is positioned at x: 400; y: 400.

      If the app is started on screen 1, the positioning is correct.

      If the app is started on screen 2, the window is somewhere else than it should be.

      This may be related to mixing scaled values with non-scaled values when calculating position. If I dump the contents of Qt.application.screens, I get the following on my system:

      qml: 0 : name:  \\.\DISPLAY1
      qml: 0 : width:  2406
      qml: 0 : height:  1354
      qml: 0 : devicePixelRatio:  1.25
      qml: 0 : virtualX:  0
      qml: 0 : virtualY:  0
      qml: 0 : desktopAvailableWidth:  5312
      qml: 0 : desktopAvailableHeight:  1440
      qml: 1 : name:  \\.\DISPLAY2
      qml: 1 : width:  2304
      qml: 1 : height:  1440
      qml: 1 : devicePixelRatio:  1.25
      qml: 1 : virtualX:  3008
      qml: 1 : virtualY:  0
      qml: 1 : desktopAvailableWidth:  5312
      qml: 1 : desktopAvailableHeight:  1440
      

       virtualX is an unscaled value whereas width is scaled. desktopAvailableWidth seems to be sum of screen 2's virtualX and screen 1's width, so it is the sum of a scaled and an unscaled value. I don't know if this is related is any way, though.

      However, given the above values, the window at x: 400; y: 400 is actually at x: -202; y: 400 if started on the second screen.

      -202 happens to be x - Qt.application.screen[1].virtualX + Qt.application.screen[0].width. If screen 2's virtualX was equal to screen 1's width – as you would expect – this formula would equal to x thus 400. (Although the point of calculating it in the first place still eludes me.)

      I have attached my example app.

      (I have no idea whether the component I selected is correct.)

      Attachments

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

        Activity

          People

            tokorpip Tomi Korpipää
            tfm123 Ole
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes