Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How do you correctly handle scaling across various display sizes?

How do you correctly handle scaling across various display sizes?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 400 Views 1 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.
  • D Offline
    D Offline
    droogie
    wrote on last edited by
    #1

    Hello,

    I'm working on a basic calculator application and have configured it to be a fixed window size. Using this setup on my main machine works fine and as expected, although when I build my project on new macbook the window widgets are squished. In addition to being squished, it appears that the code I use to obtain the coordinates of certain widgets and drawtext based on those values is also incorrect. Right now I thought I would get away with using fixed numbers but it appears that the difference in screen resolution may be impacting the drawing?

    To make things easier instead of me guessing where issues are and attempting to share snippets, here is a link to the full source: https://github.com/droogie/bincalc

    Feel free to ask for clarification on anything specific, this is my first Qt project so I might be doing things in an incorrect or confusing manner.

    This is it looking correctly on linux:
    alt text

    This is how it displays on a macbook:
    alt text

    At first glance the most obvious difference was the column size for the main gridlayout. I messed with adjusting columnspacing values to give the first column a larger width, thinking that it might solve the issue although I was not getting expected results. I am also fearing that my approach of drawing text (making the vertical labels for the bit checkboxes) is probably not the correct way to handle the situation and would love some recommendations regarding that if anyone has any.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to decent,

      From a quick check, you are using hard coded values that play fine at standard resolution but not on retina displays.

      Did you already check the high dpi chapter in Qt's documentation ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        droogie
        wrote on last edited by
        #3

        Thanks for the reply. Looking at the documentation and messing with some of the attributes, it seems that since I'm using qt6 all of the high dpi settings are automatically enabled. I've toyed with different settings with no differences and also warnings of attributes being deprecated and them no longer taking effect.

        I'm curious if there's a separate difference between the environments that's causing the columns to be sized differently? The main widget is in a grid layout and we can see the left column is being squished in the MacOS build due to the right column being unnecessarily wide. Any thoughts?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          What I think happens is that you do not take into account the devicePixelRatio into your paint maths. So it works fine as long as you are working on a screen which has a 1:1 ratio but as soon as you get on a retina display for example, you are working with a 2:1 ratio.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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