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

Robert Iakobashvili coroberti at gmail.com
Mon Jun 30 11:23:17 CEST 2014


On Mon, Jun 30, 2014 at 8:00 AM, Robert Iakobashvili <coroberti at gmail.com>
wrote:

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

To add that the physical size detection code works
properly with Qt-5.3.0.

It appears that it was broken by Qt-5.3.1

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


More information about the Android-development mailing list