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. How to get Screen scale?
Forum Updated to NodeBB v4.3 + New Features

How to get Screen scale?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 4.1k 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.
  • Z Offline
    Z Offline
    zhangXianxiang
    wrote on last edited by
    #1

    ![alt text](0_1535963517633_111.png image url)

    As shown above,How can I get this data from QML?

    import QtQuick.Window 2.0
    Screen method is available?

    DiracsbracketD 1 Reply Last reply
    0
    • Z zhangXianxiang

      ![alt text](0_1535963517633_111.png image url)

      As shown above,How can I get this data from QML?

      import QtQuick.Window 2.0
      Screen method is available?

      DiracsbracketD Offline
      DiracsbracketD Offline
      Diracsbracket
      wrote on last edited by Diracsbracket
      #2

      @zhangXianxiang
      A bit late, but you can try this:

      QApplication app(argc, argv);
      qDebug() << (app.desktop()->logicalDpiX()/96.0)*100.0;
      

      You can pass the value to the QML context, if you wish.

      1 Reply Last reply
      2
      • Z Offline
        Z Offline
        zhangXianxiang
        wrote on last edited by
        #3

        nice , thank you very much🤓

        DiracsbracketD 1 Reply Last reply
        0
        • Z zhangXianxiang

          nice , thank you very much🤓

          DiracsbracketD Offline
          DiracsbracketD Offline
          Diracsbracket
          wrote on last edited by Diracsbracket
          #4

          @zhangXianxiang
          I don't know however how to get the default DPI value (96 on my Windows PC).

          From
          https://en.wikipedia.org/wiki/Dots_per_inch
          this default value seems to be 72 for Mac:

          Since the 1980s, the Microsoft Windows operating system has set the default display "DPI" to 96 PPI, while Apple/Macintosh computers have used a default of 72 PPI.

          In any case, if your problem is answered, could you mark this question as solved?
          Cheers.

          1 Reply Last reply
          3
          • Z Offline
            Z Offline
            zhangXianxiang
            wrote on last edited by
            #5

            i'm sorry, I seem have forgotten

            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