Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect hiDPI mode

Tags:

qt

qt4

qt4.8

Working with Qt 4.8.4 on OS X -- Desktop Application development. I need to be able to detect, at paint time, if I am on a hiDPI display ("retina") or not. Does anyone know how to achieve this?

like image 235
JasonGenX Avatar asked May 13 '13 17:05

JasonGenX


People also ask

What is HiDPI mode?

Software support to boost the spread of super high pixel density displays. Support for the high pixel density display environment in the PC OS is called HiDPI support.

What is HiDPI mode Mac?

And here's what HiDPI mode looks like with an effective resolution of 960×600: Although it may be difficult to discern on your own display (you can click on each image to view them larger), the HiDPI mode makes macOS and apps look much crisper, but significantly reduces the working resolution of the system.

How do I turn off HiDPI on Mac?

you can disable this by going to system preferences - then to energy saver. in the top left corner is a box you can tick or untick with the option to let high sierra decide to use automatic graphics switching or not. hope that helps.

What is HiDPI monitor?

HiDPI (High Dots Per Inch) displays, also known by Apple's "Retina Display" marketing name, are screens with a high resolution in a relatively small format. They are mostly found in high-end laptops and monitors. Not all software behaves well in high-resolution mode yet.


1 Answers

You can use QScreen for this in Qt 5, and in Qt 4 you can use the QSystemDisplayInfo class from Qt Mobility.

For Qt 4

There is QSystemDisplayInfo - http://doc.qt.digia.com/qtmobility/qsystemdisplayinfo.html

The relevant methods are getDPIHeight and getDPIWidth.

You could also use QDesktopWidget's physicalDpiX and physicalDpiY methods.

For Qt 5

Use QScreen - http://qt-project.org/doc/qt-5.0/qtgui/qscreen.html#physicalDotsPerInch-prop

((QGuiApplication*)QCoreApplication::instance())
    ->primaryScreen()->physicalDotsPerInch()

There are also physicalDotsPerInchX and physicalDotsPerInchY.

like image 181
Venemo Avatar answered Sep 17 '22 20:09

Venemo