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)?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 900 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.
  • M Offline
    M Offline
    mzimmers
    wrote on 7 Dec 2022, 19:19 last edited by mzimmers 12 Jul 2022, 19:20
    #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 8 Dec 2022, 02:11 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.

      M 1 Reply Last reply 8 Dec 2022, 16:48
      2
      • C ChrisW67
        8 Dec 2022, 02:11

        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.

        M Offline
        M Offline
        mzimmers
        wrote on 8 Dec 2022, 16:48 last edited by mzimmers 12 Aug 2022, 17:38
        #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...

        M 1 Reply Last reply 4 Jan 2023, 19:12
        0
        • M mzimmers
          8 Dec 2022, 16:48

          @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...

          M Offline
          M Offline
          mzimmers
          wrote on 4 Jan 2023, 19:12 last edited by
          #4

          BTT: anyone have any ideas on this?

          J 1 Reply Last reply 4 Jan 2023, 19:29
          0
          • M mzimmers
            4 Jan 2023, 19:12

            BTT: anyone have any ideas on this?

            J Offline
            J Offline
            JoeCFD
            wrote on 4 Jan 2023, 19:29 last edited by JoeCFD 1 Apr 2023, 19:34
            #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
            • M Offline
              M Offline
              mzimmers
              wrote on 4 Jan 2023, 19:35 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...

              J 1 Reply Last reply 4 Jan 2023, 19:43
              0
              • M mzimmers
                4 Jan 2023, 19:35

                @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...

                J Offline
                J Offline
                JoeCFD
                wrote on 4 Jan 2023, 19:43 last edited by JoeCFD 1 Apr 2023, 19:48
                #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.

                M 1 Reply Last reply 4 Jan 2023, 19:54
                0
                • J JoeCFD
                  4 Jan 2023, 19:43

                  @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.

                  M Offline
                  M Offline
                  mzimmers
                  wrote on 4 Jan 2023, 19:54 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".

                  J 1 Reply Last reply 4 Jan 2023, 20:05
                  0
                  • M mzimmers
                    4 Jan 2023, 19:54

                    @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".

                    J Offline
                    J Offline
                    JoeCFD
                    wrote on 4 Jan 2023, 20:05 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