Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Device-independent-pixel sizing in Qt 5.6
Forum Updated to NodeBB v4.3 + New Features

Device-independent-pixel sizing in Qt 5.6

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
dpihighdpi
1 Posts 1 Posters 1.7k 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.
  • vikramgV Offline
    vikramgV Offline
    vikramg
    wrote on last edited by
    #1

    tl;dr: Does Qt 5.6 ensure that QML element sizes are interpreted in device-independent pixel units when Qt::AA_EnableHighDpiScaling is set?


    I'm trying to wrap my head around the high-DPI support in Qt. There are numerous posts/articles on the topic, including periodic forum questions here.

    http://blog.qt.io/blog/2016/01/26/high-dpi-support-in-qt-5-6/
    http://blog.qt.io/blog/2013/04/25/retina-display-support-for-mac-os-ios-and-x11/
    http://doc.qt.io/qt-5/highdpi.html

    However, I still haven't found a practical usage example of how to avail of it. In Android, you use Device Independent Pixels (dp) to specify dimensions of layout elements, and can thereafter forget about screen dpi. How do you do this in Qt? There seems to be a passing reference to the fact that coordinates are in device-indep pixels in QML here:
    http://blog.qt.io/blog/2013/04/25/retina-display-support-for-mac-os-ios-and-x11/

    "for app developers this doesn’t matter, you can do most of your work in the comfort of the device-independent pixel space while Qt and/or the OS does the heavy lifting"

    However this video:
    https://youtu.be/nNyhsdX6BsI?t=6m31s
    suggests computing scale factors on your own and seems to specify number of actual screen pixels as element width/height values.

    So which is correct? When you specify for example:

        Rectangle {
            width: 200
            height: 100
            . . . 
        }
    

    Are the numeric values automatically device-independent in Qt 5.6? Or do they become dev-independent only when Qt::AA_EnableHighDpiScaling is set (and are actual display pixels otherwise)? Or is neither of these true?

    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