I need to get the DPI value of display in QT. I am able to get it in QT 5.0 using the following:
#include <QScreen>
......
......
QScreen *srn = QApplication::screens().at(0);
qreal dotsPerInch = (qreal)srn->logicalDotsPerInch();
But the same code throws error in QT 4.x version. My project developed in QT 4.x version. So I need the equivalent of the above code in QT 4.x version.
Another way of getting information in Qt5:
QWidget contain physicalDpiX, physicalDpiY, logicalDpiY et cetera...
(QWidget inherit them from QPaintDevice.)
(thought the OP said Qt4, but Qt5 is in development currently.)
Story:
I was facing the same issue.
After @code_fodder answer (though in-complete but still deserve credit).
mentioned of QPaintDevice contain those relevant methods.
after reading more over, in noticed,
QWidget inherits QObject and QPaintDevice and when i saw, that was it!.
In Qt 4.8 this seem to do the trick:
I think this is a Qt5 addition. For Qt4 or older (I think its supported in 3... but can't remember) you can use the QPaintDevice to get similar information, here are the functions that will be useful to you depending what you need to do:
Note: This is not an implementation, just example function calls.