[Android-development] Physical Screen Sizes in Qt-5.3.1

Robert Iakobashvili coroberti at gmail.com
Mon Jun 30 07:00:34 CEST 2014


Gentlemen,

To detect the physical size of a device,
the following code was effective with Qt-5.2.1
and run from main() before calling to:

 mainWindow.show();
 int rval = appl.exec();

// Screen size detection code:

QScreen* firstScreen =  QGuiApplication::primaryScreen();

if (firstScreen)
{
        qreal widthMM = firstScreen->physicalSize().width();
        qreal heightMM = firstScreen->physicalSize().height();
        qreal diagonalMM = sqrt(widthMM*widthMM + heightMM*heightMM);
        this->screen_inches_size_ = diagonalMM/25.0;
        qDebug() << "Screen (first) Inches Size is: " <<
this->screen_inches_size_;
}

Now, the sizes are just zeroes if called prior to mainWindow.show();
 int rval = appl.exec();

Where's the right place to call it Qt-5.3.1, and what are the best practices
to detect the physical sizes of an Android device at the latest Qt?

Thank you in advance.

Regards,
Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/android-development/attachments/20140630/44eecce2/attachment.html>


More information about the Android-development mailing list