Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. How to get correct screen size in PyQt6?
Qt 6.12 LTS is out! See what's new in the release blog

How to get correct screen size in PyQt6?

Scheduled Pinned Locked Moved Solved Qt 6
4 Posts 2 Posters 8.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tipala
    wrote on last edited by tipala
    #1

    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 correct

    any Idea?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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()

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • T Offline
        T Offline
        tipala
        wrote on last edited by
        #3

        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 values

        If 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) -> ok

        With 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 !

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tipala
          wrote on last edited by
          #4

          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 needed

          This is definitiv a different behavior between pyqt 6 and 5

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt
          • Unsolved