Home > database >  Scalability Qt 5.15 Android
Scalability Qt 5.15 Android

Time:07-04

Since it is incredibly difficult to find a developer of android applications for qt, I will ask a question here, suddenly someone was doing this.

How to solve the scalability problem on different devices? Ideally, the application should look the same on all screens, from m/hdmi to xhdpi, if there were only 6 types of screens, the task would be much easier, but in fact there are a huge number of phones with a variety of screen sizes, for example, 1280x2500.

Everything is clear with icons, qt under the hood takes icons from folders 20x20, 20x20@2 etc. But with the positioning and sizes of fields, buttons, etc., not everything is so simple, in any case margin and padding will be needed during development, sometimes even a static size needs to be set, but how to make them look the same is the question.

The official Qt documentation suggests using layouts, but for example on the authorization page, where there is a large logo and 2-3 fields, it is difficult to use layouts, and there are many examples of pages where layouts would be very difficult to use. If without layouts, qt suggests doing something like this:

height: Screen.height / 13.63321
anchors.leftMargin: Screen.width / 31.5764

But I'm not sure if this is the right way, it looks strange. There is also an option to use:

property int dpi: Screen.pixelDensity * 25.4

But this method does not always work, perhaps there is some way that I do not know about. If you have been developing for android on qt, please tell how you solved this problem?

CodePudding user response:

In our case, we did not want to fill entire Pad and/or TV screen, and our appraoch for handling responsive-size was to:

  • Make size-preset: find our prefered screen-size-preset, on which we base all view constants (sizes).

    We did pick 320x548, which is smallest iPhone safe-area.

  • Fit-to-screen: hard-code said size-preset into a helper-class, which does calculate and resize said-constants to fit on current-screen.

    Where we always use short-dimension (320) in calculation (but long-dimension can be used instead, at least, for views that support scroll-bar).

  • Document: mention screen-preset in README.md file.

Example

screens

  • Related