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. android screen width always 360?
Qt 6.11 is out! See what's new in the release blog

android screen width always 360?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 1.2k 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.
  • P Offline
    P Offline
    pyhk
    wrote on last edited by
    #1

    hi all,

    i am new to qml on android. i have created a sample app (using qt creator's "Qt Quick Application - Empty") , put the code below in main.cpp, and then run it on android devices,

    QScreen* primaryscreen = QGuiApplication::primaryScreen();
    QRect rect = primaryscreen->geometry();
    qreal width = qMin(rect.width(), rect.height());
    qreal height = qMax(rect.width(), rect.height());
    qDebug() << "w: " << (width) << ", h: " << (height);
    

    oneplus one (android 7.1.2), w: 360, h: 640
    redmi 5 (android 7.1.2), w: 360, h: 660
    Huawei P10 plus (android 7.1.2), w: 360, h: 660

    it seems width is always 360 and height is around 600 something, although the native resolution of all 3 devices are very different. i googling around and can't find doc explaining this 360 figure.

    is it a expected behavior?

    thx in advance!

    py

    PS: qt 5.11.2 open source, running on ubuntu 16.04 LTS

    J.HilkJ 1 Reply Last reply
    0
    • P pyhk

      hi all,

      i am new to qml on android. i have created a sample app (using qt creator's "Qt Quick Application - Empty") , put the code below in main.cpp, and then run it on android devices,

      QScreen* primaryscreen = QGuiApplication::primaryScreen();
      QRect rect = primaryscreen->geometry();
      qreal width = qMin(rect.width(), rect.height());
      qreal height = qMax(rect.width(), rect.height());
      qDebug() << "w: " << (width) << ", h: " << (height);
      

      oneplus one (android 7.1.2), w: 360, h: 640
      redmi 5 (android 7.1.2), w: 360, h: 660
      Huawei P10 plus (android 7.1.2), w: 360, h: 660

      it seems width is always 360 and height is around 600 something, although the native resolution of all 3 devices are very different. i googling around and can't find doc explaining this 360 figure.

      is it a expected behavior?

      thx in advance!

      py

      PS: qt 5.11.2 open source, running on ubuntu 16.04 LTS

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      hi @pyhk said in android screen width always 360?:

      try it with availableGeometry


      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
      • P Offline
        P Offline
        pyhk
        wrote on last edited by
        #3

        thanks for pointing out availableGeometry()

        but the result is still the same. it seems QGuiApplication "masks" the underlying, real screen resolution, and QGuiApplication::primaryScreen() is always 360x600 something. at least it is what looks liked on android device.

        (i have tried a windows 10 tablet, with 3840×2160 display. the availableGeometry() returns 1920x1080. QGuiApplication does have some magic in itself)

        py

        1 Reply Last reply
        0
        • P Offline
          P Offline
          pyhk
          wrote on last edited by
          #4

          oh, my mistake.

          i haven't paid attention to the very 1st line of code in the main.cpp, which is:

          QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
          

          after changing it to AA_DisableHighDpiScaling, the geometry(), availableGeometry(), etc work as expected.

          thanks

          py

          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