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.
QT_SCALE_FACTOR [numeric] defines a global scale factor for the whole application, including point-sized fonts. QT_SCREEN_SCALE_FACTORS [list] specifies scale factors for each screen. This won't change the size of point-sized fonts.
I'km working in Qt, i need help to get the physical size of the screen (monitor),
In Qt one can get a QDesktopWidget
from QApplication
, I mean:
QDesktopWidget *mydesk = QApplication::desktop();
The QDesktopwidget
has some methods to get the resolution in pixels and some to get the the size in milimethers:
mydesk-> widthMM(); mydesk->heightMM();
However, this does not correspond to the physical size, when I measure my screen with a ruler, there is a considerable difference.
Also one can get the DPI measurement and calculate the size of the screen:
mydesk->physicalDpiX(); mydesk->physicalDpiY();
double Winches = (double)mydesk.width() / (double)mydesk.physicalDpiX();
double Hinches = (double)mydesk.Height() / (double)mydesk.physicalDpiY();
where mydesk.width()
and mydesk.height()
give the size in pixels(resolution)
However the measurement is also wrong and very close to mydesk.widthMM()
and mydesk.heightMM()
Also I have triyed mydesk.logicalDpiX()
and it has similar results.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With