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. What is the correct way to use Text component to support multiple DPIs?

What is the correct way to use Text component to support multiple DPIs?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
font sizedpitextmobile app deveresponsive
4 Posts 3 Posters 881 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.
  • D Offline
    D Offline
    diredko
    wrote on last edited by
    #1

    I’m trying to implement a simple mobile app in QML and currently I’m stuck with specifying proper font sizes (and other properties) of Text components so that they look similar on devices with different DPI.
    What is correct way to use Text components in QML application to support different DPIs with single code?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      We also had similar problem statement. We took the approach of reading the Screen Size, DPI. Based on these we calculated the different font size etc for different devices.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      D 1 Reply Last reply
      0
      • dheerendraD dheerendra

        We also had similar problem statement. We took the approach of reading the Screen Size, DPI. Based on these we calculated the different font size etc for different devices.

        D Offline
        D Offline
        diredko
        wrote on last edited by
        #3

        @dheerendra thank you for your response :) I also tried calculating font size manually but the result was insufficient.
        I would greatly appreciate if you could provide some more details on your approach:

        • how did you obtain screen size and DPI (it is possible that I used wrong values)?
        • how did you calculate font size based on screen size and DPI (I calculated ratio between reference DPI and device DPI and multiplied it by reference font size)?
        • did you use pixelSize of pointSize for you texts?
        • did you take into account different DPIs over X and Y axises? If yes, how?
        J.HilkJ 1 Reply Last reply
        0
        • D diredko

          @dheerendra thank you for your response :) I also tried calculating font size manually but the result was insufficient.
          I would greatly appreciate if you could provide some more details on your approach:

          • how did you obtain screen size and DPI (it is possible that I used wrong values)?
          • how did you calculate font size based on screen size and DPI (I calculated ratio between reference DPI and device DPI and multiplied it by reference font size)?
          • did you use pixelSize of pointSize for you texts?
          • did you take into account different DPIs over X and Y axises? If yes, how?
          J.HilkJ Online
          J.HilkJ Online
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @diredko
          you can take a look at the Scalability section of the documentation

          The calculating scaling ratio section has an example that used to help me a lot when I first was confronted with this issue.


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          2

          • Login

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