Andrea993 Andrea993 - 4 months ago 40
Android Question

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

Answer

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.

Comments