How to get correct screen size in PyQt6?
-
in pyqt6 in all cases I got the not the correct dimensions of my screen:
QGuiApplication.primaryScreen().availableGeometry()shows only:
PyQt6.QtCore.QRect(0, 0, 2048, 1112)in pyqt5
QApplication.desktop().screenGeometry() I got
PyQt5.QtCore.QRect(0, 0, 2560, 1440) which is correctany Idea?
-
@tipala said in How to get correct screen size in PyQt6?:
availableGeometry()
screenGeometry()
do you spot the difference?
If you want the screenGeometry, you should call screenGeometry() and not availableGeometry() -
HIi Christian,
thanks for your answer, but it seems not the solution:I also tried:
screen_resolution = QGuiApplication.primaryScreen().geometry()
print(screen_resolution)
Result :
PyQt6.QtCore.QRect(0, 0, 2048, 1152) -> false valuesIf I try to downgrade the screen resolution to e.g. 1600 x 1200
screen_resolution = QGuiApplication.primaryScreen().geometry()
print(screen_resolution)
Result:
PyQt6.QtCore.QRect(0, 0, 1600, 1200) -> okWith availableGeometry() it seems similar
resultion 2560 x 1440 leads to PyQt6.QtCore.QRect(0, 0, 2048, 1112)
resultion 1600 x 1200 leads to PyQt6.QtCore.QRect(0, 0, 1600, 1160)So it seems it depends mainly on the resolution
any idea so far ?
Thanks !
-
It seems I found a reson for that
on Windows apart of the screen resolution it's possible to adjust the size of text, apps etc.
This was set on 125% on the desktop from with I tried. After setting to 100%
result is
PyQt6.QtCore.QRect(0, 0, 2560, 1440) as neededThis is definitiv a different behavior between pyqt 6 and 5