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