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. Adjusting constant sizes to DPI
Forum Updated to NodeBB v4.3 + New Features

Adjusting constant sizes to DPI

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 247 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    Adjusting QML to the system's DPI settings is mostly automatic: Fonts and images grow implicitly, and if my design honors these implicit sizes, the output should be nice.

    There is just one missing link for me: In some cases, I want to have a hard-coded minimum size. For example, a button should grow as more text is displayed, but it should never shrink below a certain size.

    This can be done easily by taking the maximum of the (implicit) text size and the minimum size.

    However, the minimum size is given in pixels, so it would need to be multiplied by a factor depending on the DPI used in the design vs. the system DPI.

    Is there a QML way to do it? My best idea right now is to register some context property or similar with this scaling factor, and multiply every constant size with that.

    ODБOïO 1 Reply Last reply
    0
    • A Asperamanca

      Adjusting QML to the system's DPI settings is mostly automatic: Fonts and images grow implicitly, and if my design honors these implicit sizes, the output should be nice.

      There is just one missing link for me: In some cases, I want to have a hard-coded minimum size. For example, a button should grow as more text is displayed, but it should never shrink below a certain size.

      This can be done easily by taking the maximum of the (implicit) text size and the minimum size.

      However, the minimum size is given in pixels, so it would need to be multiplied by a factor depending on the DPI used in the design vs. the system DPI.

      Is there a QML way to do it? My best idea right now is to register some context property or similar with this scaling factor, and multiply every constant size with that.

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      hi
      @Asperamanca said in Adjusting constant sizes to DPI:

      My best idea right now is to register some context property or similar with this scaling factor, and multiply every constant size with that.

      I think that is the right thing to do.
      https://doc.qt.io/qt-5/scalability.html

      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