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. how to enforce fixed display size (in inches, not pixels)?
QtWS25 Last Chance

how to enforce fixed display size (in inches, not pixels)?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 772 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by mzimmers
    #1

    Hi all -

    So, here's the deal - I'm writing a demo for an app that will end up on a 5" LCD display on our product. Sales and marketing would like to show the demo on their Android tablets, but their tablets have 8" screens. (How) can I make my demo only use 5" of screen?

    Thanks...

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      This do it for you?

      Use QScreen to get the displaying device's physical pixels per inch values, compute the number of pixels in each direction to make the physical size you want, and set your top-most Window geometry.

      mzimmersM 1 Reply Last reply
      2
      • C ChrisW67

        This do it for you?

        Use QScreen to get the displaying device's physical pixels per inch values, compute the number of pixels in each direction to make the physical size you want, and set your top-most Window geometry.

        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by mzimmers
        #3

        @ChrisW67 thanks for the suggestion. I neglected to mention that I'm using QML for all of my display elements. I'm also using Qt 6.4. I see that there's a Screen QML type in Qt 5, but I don't find any mention of it in the 6.4 documentation, so I'm wondering whether I shouldn't use it. It does seem to work, though.

        Using Screen, I can obtain pixelDensity, which is (I think) similar to QScreen's physicalDotsPerInch (except it's in mm not inches). The reported density is ~3.64. I'll leave out the math here, but it looks like I want my blank area to be 75 pixels wide (on all four sides).

        Assuming I'm right so far, how do I shrink my display region? I guess I could use x and y to move it over and to the right, but how do I get it to fit into my smaller area?

        EDIT: I tried putting a transparent rectangle (with anchor margins of 75) in my ApplicationWindow, and putting everything else into the rectangle. This sort of works, but I've got a lot of clean-up to do to get everything sizing correctly. I don't mind the work, but...is this the right approach?

        Thanks...

        mzimmersM 1 Reply Last reply
        0
        • mzimmersM mzimmers

          @ChrisW67 thanks for the suggestion. I neglected to mention that I'm using QML for all of my display elements. I'm also using Qt 6.4. I see that there's a Screen QML type in Qt 5, but I don't find any mention of it in the 6.4 documentation, so I'm wondering whether I shouldn't use it. It does seem to work, though.

          Using Screen, I can obtain pixelDensity, which is (I think) similar to QScreen's physicalDotsPerInch (except it's in mm not inches). The reported density is ~3.64. I'll leave out the math here, but it looks like I want my blank area to be 75 pixels wide (on all four sides).

          Assuming I'm right so far, how do I shrink my display region? I guess I could use x and y to move it over and to the right, but how do I get it to fit into my smaller area?

          EDIT: I tried putting a transparent rectangle (with anchor margins of 75) in my ApplicationWindow, and putting everything else into the rectangle. This sort of works, but I've got a lot of clean-up to do to get everything sizing correctly. I don't mind the work, but...is this the right approach?

          Thanks...

          mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote on last edited by
          #4

          BTT: anyone have any ideas on this?

          JoeCFDJ 1 Reply Last reply
          0
          • mzimmersM mzimmers

            BTT: anyone have any ideas on this?

            JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by JoeCFD
            #5

            @mzimmers What I did is always using full screen. Then scale all items with screen size and everything is done with pixels(font as well). Bilinear scaling does not work all the time and you need to twist a bit. The scaling can be done in one specific class at start-up.

            1 Reply Last reply
            0
            • mzimmersM Offline
              mzimmersM Offline
              mzimmers
              wrote on last edited by
              #6

              @JoeCFD said in how to enforce fixed display size (in inches, not pixels)?:

              scale all items with screen size

              Not sure what you mean by that. How would I apply this to my example of putting a 75px black border around the main display?

              Thanks...

              JoeCFDJ 1 Reply Last reply
              0
              • mzimmersM mzimmers

                @JoeCFD said in how to enforce fixed display size (in inches, not pixels)?:

                scale all items with screen size

                Not sure what you mean by that. How would I apply this to my example of putting a 75px black border around the main display?

                Thanks...

                JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by JoeCFD
                #7

                @mzimmers border has to be scaled only in one direction.
                For example, I select a reference screen 1920*1080. The border of your app is 75px
                Now you have a screen 1280 * 800 on an Android Tablet. The border will be 75 * 1280 / 1920.0. I do not think you want to keep a 75px border on this screen, right?

                Find a good artist to define the aspect ratios of all components for you. Your app will look different.

                mzimmersM 1 Reply Last reply
                0
                • JoeCFDJ JoeCFD

                  @mzimmers border has to be scaled only in one direction.
                  For example, I select a reference screen 1920*1080. The border of your app is 75px
                  Now you have a screen 1280 * 800 on an Android Tablet. The border will be 75 * 1280 / 1920.0. I do not think you want to keep a 75px border on this screen, right?

                  Find a good artist to define the aspect ratios of all components for you. Your app will look different.

                  mzimmersM Offline
                  mzimmersM Offline
                  mzimmers
                  wrote on last edited by
                  #8

                  @JoeCFD the purpose of this exercise is to "shrink" my display, so that people can see what it will look like on the (smaller) target display. My Android emulator has an 8" screen, but the target screen will be most likely 5".

                  JoeCFDJ 1 Reply Last reply
                  0
                  • mzimmersM mzimmers

                    @JoeCFD the purpose of this exercise is to "shrink" my display, so that people can see what it will look like on the (smaller) target display. My Android emulator has an 8" screen, but the target screen will be most likely 5".

                    JoeCFDJ Offline
                    JoeCFDJ Offline
                    JoeCFD
                    wrote on last edited by
                    #9

                    @mzimmers if you think two(or more) devices may have different resolutions, you might not have a lot of choices.

                    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