Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Does QWidget::width() always return width in number of pixels?
Forum Updated to NodeBB v4.3 + New Features

Does QWidget::width() always return width in number of pixels?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 1.1k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    Simmania
    wrote on 18 Apr 2022, 18:52 last edited by
    #1

    Hi,
    I'm a little confused.
    I have a monitor set to a resolution of 3840 x 2160.
    When a have a full screen Qt window with a QWIdget such that the widget has maximum width (almost the entire screen), the width() function of this widget still returns only about 2530. While I expected a value close to 3840. How is that possible?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 18 Apr 2022, 19:03 last edited by
      #2

      Hi,

      Any chances you have a scaling factor of 1.5 set for that screen ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Simmania
        wrote on 18 Apr 2022, 20:44 last edited by Simmania
        #3

        No,
        I didn;t set anything.
        When I add:

        painter.scale(1.0, 1.0);
        

        the result doesn't change.

        J 1 Reply Last reply 19 Apr 2022, 07:55
        0
        • S Offline
          S Offline
          Simmania
          wrote on 19 Apr 2022, 07:43 last edited by
          #4

          I tested on an other computer. With resolution 1920x1080. On that one width() returns the number of pixels correctly.
          Is there some limit on screen size above which Qt is doing some scaling internally?

          1 Reply Last reply
          0
          • S Simmania
            18 Apr 2022, 20:44

            No,
            I didn;t set anything.
            When I add:

            painter.scale(1.0, 1.0);
            

            the result doesn't change.

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 19 Apr 2022, 07:55 last edited by
            #5

            @Simmania said in Does QWidget::width() always return width in number of pixels?:

            No,
            I didn;t set anything.
            When I add:
            painter.scale(1.0, 1.0);

            I think what @SGaist was asking was: is a scaling factor set in your OS for that screen?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Simmania
              wrote on 19 Apr 2022, 17:23 last edited by
              #6

              Aah. Yes there was! Thx!
              So that means you never can be sure the width() is expressed in pixels. Hmm.

              C 1 Reply Last reply 19 Apr 2022, 17:33
              0
              • S Simmania
                19 Apr 2022, 17:23

                Aah. Yes there was! Thx!
                So that means you never can be sure the width() is expressed in pixels. Hmm.

                C Offline
                C Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 19 Apr 2022, 17:33 last edited by
                #7

                @Simmania said in Does QWidget::width() always return width in number of pixels?:

                So that means you never can be sure the width() is expressed in pixels

                How should the OS add this scale factor otherwise?

                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
                0

                1/7

                18 Apr 2022, 18:52

                • Login

                • Login or register to search.
                1 out of 7
                • First post
                  1/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved