Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Getting screen size of Android virtual device
Servers for Qt installer are currently down

Getting screen size of Android virtual device

Scheduled Pinned Locked Moved Solved Mobile and Embedded
6 Posts 3 Posters 1.5k 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.
  • T Offline
    T Offline
    Treazy
    wrote on last edited by A Former User
    #1

    All,

    'am running the following code snippet in Qt to get the screen size of my android virtual device.

    QApplication app(argc, argv);
     
     QDesktopWidget *mydesk = app.desktop();
        // redundant but using both showFullScreen and showMaximized...
        // ...just to play it safe
        mydesk->showMaximized();
        mydesk->showFullScreen(); 
    
      QScreen *screen = app.primaryScreen();
        int width = screen->size().width();
        int height = screen->size().height();
    

    I created a Nexus 5 Android Virtual Device with resolution 1080x1920 to test my code and my width and height values are 1080x1776 instead of the expected 1080x1920. What 'am I doing wrong here? Can someone please help me?

    Thanks

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

      Hi,

      Just a wild guess, but isn't that the size without the top bar ?

      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
      1
      • T Offline
        T Offline
        Treazy
        wrote on last edited by
        #3

        Thanks @SGaist. My guess was the same but I do not know how to prove it. Any thoughts?

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

          Does your application cover the status bar ?

          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
          1
          • T Treazy

            Thanks @SGaist. My guess was the same but I do not know how to prove it. Any thoughts?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Treazy
            Hi
            You dont really have to prove it.
            Many other have wondered.
            https://forum.xda-developers.com/xperia-z/general/hd-t2238929

            1080x1776 too much a magic number to be a coincidence ( IMHO)

            I wonder when you create a Nexus 5 Android Virtual Device, it must know from some where
            the size of the bar.

            But if app covers bar ( as @SGaist asks) then it might be bug in the virtual device as as far as i know
            (some) info apps will report full size if app is fullscreen.

            1 Reply Last reply
            1
            • T Offline
              T Offline
              Treazy
              wrote on last edited by
              #6

              Thanks @SGaist and @mrjj . My app does not cover the status bar. It is just a test app/Hello World type app that displays the resolution on the screen (so not much to the code than what i posted here). I will try creating an app that covers the status bar and see how that behaves.

              Thanks again

              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