How to get screen size in Qt

Posted on Posted in Android Tutorials, Qt Tutorials, Tutorials

Qt includes a very simple method to get the size of the screen (width and height). Here it is:

QSize size = qApp->screens()[0]->size();

Note that this function works perfectly in Android and iOS too.

Another thing to note is that if you replace [0] with 1, 2, 3, … you can access other monitors (if there are any) on desktop computers.

One thought on “How to get screen size in Qt

Leave a Reply

Your email address will not be published. Required fields are marked *