Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Android. Get device screen resolution

I'm developing in qt 5.3 on android device. I can't get the screen resolution. With the old qt 5 version this code worked:

QScreen *screen = QApplication::screens().at(0);
largh=screen->availableGeometry().width();
alt  =screen->availableGeometry().height();

However now it doesn't work (returns a screen size 00x00). Is there another way to do it? thanks

like image 683
Andrea993 Avatar asked Jul 11 '14 19:07

Andrea993


People also ask

How do I find my screen resolution on Android?

Method 1 of 2: Tap the icon in your Apps menu or home screen to open the Settings menu. You can also swipe down from the top of the screen and then tap the gear icon in the resulting drop-down menu. Not all Android phones have the option to change your screen resolution in the Settings menu.

Can I use Qt for Android?

Qt for Android enables you to develop Qt applications for Android devices, and supports a wide range of features and use-cases. To download and install Qt for Android, follow the instructions on the Getting Started with Qt for Android page. To build Qt from source, see Building from Source.


1 Answers

Size holds the pixel resolution

screen->size().width()
screen->size().height();

Whereas, availableSize holds the size excluding window manager reserved areas...

screen->availableSize().width()
screen->availableSize().height();

More info on the QScreen class.

like image 55
Zeus Avatar answered Sep 20 '22 01:09

Zeus