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. QML Application and HiDPI
Forum Updated to NodeBB v4.3 + New Features

QML Application and HiDPI

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 1.3k Views
  • 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
    maxwell31
    wrote on last edited by
    #1

    Hi,

    I am developing a new qml desktop application, and want to make sure it runs on HiDPI screens as well as on normal screens. I found https://doc.qt.io/qt-5.10/highdpi.html but still I dont know what practices I should follow when designing my app. The documentation says

    Replace hard-coded sizes in layouts and drawing code by values calculated from font metrics or screen size.

    Are there other things to consider? Also, how would this be done in practice (e.g. get the font metric or the screen size). Once I have them, and e.g. I define a rectangle, should I then define it like ceil(0.3*screenSize)? I guess I should try to always have integer pixels right?

    Would it be a good idea to define a global scaling value, and multiply every width by this value?

    1 Reply Last reply
    0
    • timdayT Offline
      timdayT Offline
      timday
      wrote on last edited by
      #2

      @maxwell31 Generally on HighDPI ("retina") screens even if the screen is UHD 3840x2160 resolution your QML will use "logical" pixels and your code will get the impression the screen is 1920x1080. No scaling factor needed... just code as if you were coding for 1920x1080 and it should all look beautiful on a HighDPI UHD. No explicit global scaling factor required.

      All my apps are designed to run full-screen or in a big window... I mainly work top down coding everything in terms of proportions of it's parent's size (which at the top level is the screen size). Doesn't fail gracefully for small windows or extreme aspect ratios but its good enough for me (these days the main challenge is getting it to look good on all of portrait and landscape and 4:3-HD aspect ratio screens on mobile. So long as those are good, the desktop users can take their chances resizing to other goofy shapes).

      Personally I've hardly ever bothered rounding size calculations to integer pixels unless I really needed to (e.g rectangles with hard 1 pixel borders can look different depending on sub-pixel positioning and it's worth rounding... but bigger solid blocks of colour or text just work fine wherever you put them). Exactly how good it looks might depend on antialiasing settings but I've not experimented enough to comment further, or particularly felt the need to.

      1 Reply Last reply
      2
      • M Offline
        M Offline
        maxwell31
        wrote on last edited by
        #3

        Thanks for the helpfull post. You are right, once I set

            QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
        

        It is working nicely. There is one thing though, I do some drawing in updatePaintNode using openGL, there the line width is not automatically scaled, but this should also not be a big problem.

        1 Reply Last reply
        0
        • I Offline
          I Offline
          igor_stravinsky
          wrote on last edited by
          #4

          My suggestions would include:

          •using quick controls 2 as your starting point, since it was designed for higher resolutions

          •Use anchors rather than absolute pixel positions.

          •Use scalable graphics (PDFs, SVGs) rather than fixed resolution graphics, so images don't' look pixelated at higher resolution.

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved