Qt includes a very simple method to get the size of the screen (width and height). Here it is:
QSize size = qApp->screens()->size();
Note that this function works perfectly in Android and iOS too.
Another thing to note is that if you replace  with 1, 2, 3, … you can access other monitors (if there are any) on desktop computers.