Skip to content
  • 0 Votes
    2 Posts
    1k Views
    P

    @DerBaer

    The QML version did/does not scale Android UIs correctly. The Qt C++ UI may be the same.

    With the version I am using, I was forced to create a ratio based on the Android device screen resolution relative to the desktop resolution for all on screen objects..text, fonts, images, etc.

    Probably may not be what you want to hear, but you may have to handle the scaling yourself...unless this behavior has been fixed.

  • 0 Votes
    3 Posts
    2k Views
    B

    @p3c0,

    Thanks for advice. I removed clip, but unfortunately it did not help. Further testing shows that as long as image fits to 2048x2048 size there is no loss in image quality. After some searching, I am guessing that this might be caused by Android texture size limitation.

    Dealing with Android's texture size limit

    I don't know how Qt handles this internally, but it definitely looks like there is some automatic scaling happening when image is not fitting into certain size.

    Maybe there is some workaround for this. Otherwise displaying large images requires more than "image + flickable" approach.

    Bob

  • 0 Votes
    1 Posts
    701 Views
    No one has replied
  • 0 Votes
    8 Posts
    5k Views
    T3STYT

    CSS lets you use relative length units, see this:
    http://www.w3schools.com/cssref/css_units.asp

    As suggested in that link before, em and rem create perfectly scalable sizes. Don't let the name and description fool you: although the size refers to the size of the M character, they can be applied to width, height and any other CSS property as well.

    Also, if you use a main CSS class like this:

    main_class { width: 1em; height: 1em; font-size: 10em; }

    and all the other objects (or CSS styles) are childs of this class:

    main_class.div { .... } // or something like this in HTML <BODY class="main_class"> <div class="other_class">something</div> </BODY> // in C++ the BODY widget would the parent of the div widget

    You can then only change the main_class sizes, and all the child items of that class will scale accordingly to their parent. Suppose you have this CSS for that div element before:

    other_class { width: 10em; height: 4em; font-size: 1.3em; }

    and suppose that the main_class CSS is this:

    main_class { width: 3em; height; 3m; font-size: 10em; }

    then the real sizes of that other_class are actually:

    width: 30 em; // 3 * 10 height: 12 em; // 3 * 4 font_size: 13 em; // 10 * 1.3

    because they have been scaled by 3, 3 and 10ems, respectively. Using ems is for sure the best way in CSS to scale items proportionally.

    I hope this helps :)

  • Properly scaling SVG Images

    Solved QML and Qt Quick
    7
    1 Votes
    7 Posts
    13k Views
    nicwainwrightN

    Solution works! We personally just made a custom component that takes desired height, divides that into width to maintain aspect ratio, and is easy to expose a bunch of times without all this boiler plate.

    Of note, the width/height set is essential, because without it, changing the source during runtime (say if a target image needed to switch from a nondirectional to right) causes an additional instance of the image to spawn. See image below

    // Need to include this as shown in original post width: 0 height: 0

    Otherwise we get the huge version that clips out. Note: I set onSourceChanged to set color to red, so we have an idea of what the original one is and which is the artifact.
    ffe182c3-bcdd-4dc3-83ed-98f6c53aeaca-image.png