Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
None
-
6.2.1
-
None
-
Windows 10 Pro / 21H2 / Build 19044.1526
Testing with the following conda environment:
name: qt_screen_test
channels:
- anaconda
- conda-forge
- defaults
dependencies:
- ca-certificates=2021.10.8=h5b45459_0
- jpeg=9b=vc14h4d7706e_1
- libblas=3.9.0=5_hd5c7e75_netlib
- libcblas=3.9.0=5_hd5c7e75_netlib
- liblapack=3.9.0=5_hd5c7e75_netlib
- libpng=1.6.37=h2a8f88b_0
- libsodium=1.0.18=h62dcd97_0
- libtiff=4.1.0=h56a325e_1
- lz4-c=1.9.2=hf4a77e7_3
- m2w64-gcc-libgfortran=5.3.0=6
- m2w64-gcc-libs=5.3.0=7
- m2w64-gcc-libs-core=5.3.0=7
- m2w64-gmp=6.1.0=2
- m2w64-libwinpthread-git=5.0.0.4634.697f757=2
- msys2-conda-epoch=20160418=1
- ninja=1.10.2=h2d74725_1
- nomkl=1.0=h5ca1d4c_0
- numpy=1.21.4=py39h6635163_0
- openssl=3.0.0=h8ffe710_2
- pip=21.3.1=pyhd8ed1ab_0
- pybind11=2.8.1=py39h2e07f2f_1
- pybind11-global=2.8.1=py39h2e07f2f_1
- pyopengl=3.1.5=py_0
- python=3.9.7=h900ac77_3_cpython
- python_abi=3.9=2_cp39
- pywin32=302=py39hb82d6ee_2
- setuptools=59.4.0=py39hcbf5309_0
- sqlite=3.37.0=h8ffe710_0
- tzdata=2020b=h7b6447c_0
- vc=14.1=h0510ff6_4
- vs2015_runtime=14.16.27012=hf0eaf9b_3
- wheel=0.35.1=py_0
- xz=5.2.5=h62dcd97_0
- zlib=1.2.11=vc14h1cdd9ab_1
- zstd=1.4.4=ha9fde0e_3
- pip:
- nuitka==0.6.18
- pyside6==6.2.1
- shiboken6==6.2.1
Windows 10 Pro / 21H2 / Build 19044.1526 Testing with the following conda environment: name: qt_screen_test channels: - anaconda - conda-forge - defaults dependencies: - ca-certificates=2021.10.8=h5b45459_0 - jpeg=9b=vc14h4d7706e_1 - libblas=3.9.0=5_hd5c7e75_netlib - libcblas=3.9.0=5_hd5c7e75_netlib - liblapack=3.9.0=5_hd5c7e75_netlib - libpng=1.6.37=h2a8f88b_0 - libsodium=1.0.18=h62dcd97_0 - libtiff=4.1.0=h56a325e_1 - lz4-c=1.9.2=hf4a77e7_3 - m2w64-gcc-libgfortran=5.3.0=6 - m2w64-gcc-libs=5.3.0=7 - m2w64-gcc-libs-core=5.3.0=7 - m2w64-gmp=6.1.0=2 - m2w64-libwinpthread-git=5.0.0.4634.697f757=2 - msys2-conda-epoch=20160418=1 - ninja=1.10.2=h2d74725_1 - nomkl=1.0=h5ca1d4c_0 - numpy=1.21.4=py39h6635163_0 - openssl=3.0.0=h8ffe710_2 - pip=21.3.1=pyhd8ed1ab_0 - pybind11=2.8.1=py39h2e07f2f_1 - pybind11-global=2.8.1=py39h2e07f2f_1 - pyopengl=3.1.5=py_0 - python=3.9.7=h900ac77_3_cpython - python_abi=3.9=2_cp39 - pywin32=302=py39hb82d6ee_2 - setuptools=59.4.0=py39hcbf5309_0 - sqlite=3.37.0=h8ffe710_0 - tzdata=2020b=h7b6447c_0 - vc=14.1=h0510ff6_4 - vs2015_runtime=14.16.27012=hf0eaf9b_3 - wheel=0.35.1=py_0 - xz=5.2.5=h62dcd97_0 - zlib=1.2.11=vc14h1cdd9ab_1 - zstd=1.4.4=ha9fde0e_3 - pip: - nuitka==0.6.18 - pyside6==6.2.1 - shiboken6==6.2.1
Description
In my 3 screens setup, the behavior of Qt is inconsistent when managing Windows scaling and it's per-screen geometry. Some of their respective QScreens provide correctly the geometry in device-independent pixels and others in native resolution. What's more problematic: for those in which the size remained in native resolution, the device pixel ratio is the one you would expect from scaled geometry and thus, `device-independent pixels` .
To reproduce in my end, I have this screen setup configuration in Windows 10
- Screen 1:
- Native resolution: 1920x100
- Windows scaling: 150%
- Screen 2 ( Main display / primary screen):
- Native resolution: 1920x1200
- Windows scaling: 100%
- Screen 3:
- Native resolution: 1920x1080
- Windows scaling: 150%
This is my code, unfortunately not easy to reproduce given you need the same screens:
from PySide6 import QtGui, QtCore app = QtGui.QGuiApplication() print("Qt version:", QtCore.__version__) screens = app.screens() for screen in screens: print(screen.name(), screen.geometry(), screen.devicePixelRatio())
and the outcome being:
Qt version: 6.2.1 \\.\DISPLAY8 PySide6.QtCore.QRect(0, 0, 1920, 1200) 1.0 \\.\DISPLAY9 PySide6.QtCore.QRect(-1920, 0, 1920, 1080) 1.5 \\.\DISPLAY1 PySide6.QtCore.QRect(1920, 121, 1280, 720) 1.5
Note how:
- \\.\DISPLAY8 (Screen 2): is indeed showing the right resolution, and devicePixelRatio
- \\.\DISPLAY1 (Screen 1): is correctly scaling the resolution to 1280x720
- Note: (1280x720) * 1.5 = 1920x1080
- Thus this is correct
- \\.\DISPLAY9 (Screen 3): is still keeping the native resolution, but device pixel ratio is 1.5 and not 1.0
- (1920x1080 ) * 1.5 = 2880 x 1620 (????)
- Thus this is incorrect and bug
Conda environment being used (yml file):
name: qscreen_test
channels:
- anaconda
- conda-forge
- defaults
dependencies:
- ca-certificates=2021.10.8=h5b45459_0
- jpeg=9b=vc14h4d7706e_1
- libblas=3.9.0=5_hd5c7e75_netlib
- libcblas=3.9.0=5_hd5c7e75_netlib
- liblapack=3.9.0=5_hd5c7e75_netlib
- libpng=1.6.37=h2a8f88b_0
- libsodium=1.0.18=h62dcd97_0
- libtiff=4.1.0=h56a325e_1
- lz4-c=1.9.2=hf4a77e7_3
- m2w64-gcc-libgfortran=5.3.0=6
- m2w64-gcc-libs=5.3.0=7
- m2w64-gcc-libs-core=5.3.0=7
- m2w64-gmp=6.1.0=2
- m2w64-libwinpthread-git=5.0.0.4634.697f757=2
- msys2-conda-epoch=20160418=1
- ninja=1.10.2=h2d74725_1
- nomkl=1.0=h5ca1d4c_0
- numpy=1.21.4=py39h6635163_0
- openssl=3.0.0=h8ffe710_2
- pip=21.3.1=pyhd8ed1ab_0
- pybind11=2.8.1=py39h2e07f2f_1
- pybind11-global=2.8.1=py39h2e07f2f_1
- pyopengl=3.1.5=py_0
- python=3.9.7=h900ac77_3_cpython
- python_abi=3.9=2_cp39
- pywin32=302=py39hb82d6ee_2
- setuptools=59.4.0=py39hcbf5309_0
- sqlite=3.37.0=h8ffe710_0
- tzdata=2020b=h7b6447c_0
- vc=14.1=h0510ff6_4
- vs2015_runtime=14.16.27012=hf0eaf9b_3
- wheel=0.35.1=py_0
- xz=5.2.5=h62dcd97_0
- zlib=1.2.11=vc14h1cdd9ab_1
- zstd=1.4.4=ha9fde0e_3
- pip:
- nuitka==0.6.18
- pyside6==6.2.1
- shiboken6==6.2.1
Edit 1: Tested the same setup with Qt 5.15.2
This is the output:
Qt version: 5.15.2 \\.\DISPLAY8 PySide2.QtCore.QRect(0, 0, 1920, 1200) 1.0 \\.\DISPLAY9 PySide2.QtCore.QRect(-1920, 0, 1920, 1080) 1.0 \\.\DISPLAY1 PySide2.QtCore.QRect(1920, 121, 1920, 1080) 1.0
Scaling is ignored, but at least it is consistent. But, if I define
set QT_ENABLE_HIGHDPI_SCALING=1 set QT_SCALE_FACTOR_ROUNDING_POLICY=PassThrough
then the output is the correct one.
Qt version: 5.15.2 \\.\DISPLAY8 PySide2.QtCore.QRect(0, 0, 1920, 1200) 1.0 \\.\DISPLAY9 PySide2.QtCore.QRect(-1920, 0, 1280, 720) 1.5 \\.\DISPLAY1 PySide2.QtCore.QRect(1920, 121, 1280, 720) 1.5
Edit 2: After multiple experiments, this pattern emerged:
- The bug occurs on screens having a scale factor different than 100% (eg. 125% or 150%), whenever said window is not the main display, and the main display does have a scale factor of 100%.
Attachments
Issue Links
- relates to
-
QTBUG-101601 Wrong QScreen geometry for non-primary screens when scaling factors above 1
- Closed