How to get screen size in Qt

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 Reply to “How to get screen size in Qt”

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.