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. setting QT_DEVICE_PIXEL_RATIO for a specific application
Qt 6.11 is out! See what's new in the release blog

setting QT_DEVICE_PIXEL_RATIO for a specific application

Scheduled Pinned Locked Moved General and Desktop
20 Posts 4 Posters 15.2k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    I haven't tested it but from a quick look at the doc:

    [Platforms]
    WindowsArguments = dpiawareness=2
    

    might to the trick

    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
    1
    • F Offline
      F Offline
      floatingWoods
      wrote on last edited by
      #3

      Thanks Samuel,

      this (and other similar variants) don't work. I think your example just tells Qt to do automatic high-res display detection, but not force it (e.g. to test it on a low-res display system.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        Sorry, my bad, I misread the signification of the variable.

        Just one thing, do you want to do it from Qt Creator while developing your application ?

        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
        • F Offline
          F Offline
          floatingWoods
          wrote on last edited by
          #5

          Thanks,

          I need to be able to do it for the executable that is distributed.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Which version of Qt are you using ?

            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
            • F Offline
              F Offline
              floatingWoods
              wrote on last edited by
              #7

              I am using Qt 5.5

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #8

                As a workaround you could try calling qsetenv before instantiating your QApplication

                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
                1
                • F Offline
                  F Offline
                  floatingWoods
                  wrote on last edited by
                  #9

                  Thanks again!

                  This works on Windows:

                  qputenv("QT_DEVICE_PIXEL_RATIO",QByteArray("2"));
                  

                  Any similar functionality for Linux (and optionally Mac, but as far as I have tested it, Mac always recognizes high dpi displays)?

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    qputenv works also on OS X and Linux. IIRC yes OS X already handles that

                    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
                    1
                    • F Offline
                      F Offline
                      floatingWoods
                      wrote on last edited by
                      #11

                      Excellent, you are right, that also works on Linux.
                      Thanks a lot!

                      1 Reply Last reply
                      0
                      • F floatingWoods

                        Hello,

                        under Windows 8.1, I can force the pixel ratio by setting the system's environmnent variable QT_DEVICE_PIXEL_RATIO.
                        This is however applied to all my Qt applications.
                        Is it possible to set that variable specifically to one application?
                        I read about qt.conf file, but I am not sure what I have to put in there. e.g.

                        [Environment]
                        setx QT_DEVICE_PIXEL_RATIO 2
                        

                        But that has no effect. The qt.conf file is located in the same folder as my application's executable.

                        S Offline
                        S Offline
                        soudi00
                        wrote on last edited by
                        #12

                        @floatingWoods

                        Hi, I need to change the QT_DEVICE_PIXEL_RATIO to "auto" in windows 10.

                        I'm not a software developer and I have no idea how to do this I really appreciate if you can help me with this.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #13

                          Hi and welcome to devnet,

                          If it's to test your application while using Qt Creator: go to the run part of the Project panel. There you can edit the environment variables. Add a new variable with the name QT_DEVICE_PIXEL_RATIO and in value write auto.

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

                          N 1 Reply Last reply
                          0
                          • SGaistS SGaist

                            Hi and welcome to devnet,

                            If it's to test your application while using Qt Creator: go to the run part of the Project panel. There you can edit the environment variables. Add a new variable with the name QT_DEVICE_PIXEL_RATIO and in value write auto.

                            N Offline
                            N Offline
                            nikit
                            wrote on last edited by
                            #14

                            @SGaist said:

                            QT_DEVICE_PIXEL_RATIO

                            Hi,
                            I did set the variable to AUTO as you mentioned.
                            My app run fines on 1366768 screen resolution size. But if I keep my screen resolution to 1024768, UI gets cut. (cannot see buttons of my UI app).
                            What would be the probable way to fix my app to all resolution of screen?

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #15

                              Are you using layouts to handle your widgets ?

                              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
                              • N Offline
                                N Offline
                                nikit
                                wrote on last edited by
                                #16

                                Yes I am using Layouts.

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #17

                                  If your application needs a minimal size then you can put your main widget in a QScrollArea. That way if your application doesn't fit, you'll have scroll bars to move up/down to access the rest of your UI.

                                  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
                                  • N Offline
                                    N Offline
                                    nikit
                                    wrote on last edited by
                                    #18

                                    Thank you.
                                    Guess this is the last option to add Scroll in my app to support low end resolution screens

                                    1 Reply Last reply
                                    0
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #19

                                      Not really a last option. If the design of your UI is big enough to not fit some screen resolution you can either change the design to fit a larger set of screen resolution. or make it more modular under a certain size. A scrolling area is not a bad solution otherwise how would you browse internet ?

                                      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
                                      • N Offline
                                        N Offline
                                        nikit
                                        wrote on last edited by
                                        #20

                                        Yeah true. Well my app gets cut in low end resolution (1024*764). On large screen resolution its fine.

                                        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 Extensions
                                        • Unsolved