Important: Please read the Qt Code of Conduct -

Getting the screen size of an android virtual device

  • 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
      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?


Log in to reply