Retina support in Qt
-
Is there a way to determine High resolution displays (Retina displays) and specify "devicePixelRatio" for images from Stylesheets (.css) in qt?
I have .css file with the following content:
@QToolBar
{
background: url(:/images/icon.png);
background-repeat: no-repeat;
border: none;
}@I have high resolution icon (icon@2x.png), which i want to set as a background to my QToolBar in case of Retina display.
Thanks,
In Advance. -
Have a look into "QDesktopWidget":http://qt-project.org/doc/qt-5/qdesktopwidget.html. That can provide you with information about the screen and because it is a paint device it also provides dpi information. Based on that value you can decide when to use high resolution images or not.
-
Just stumbled upon something which might be interesting for you as well:
"QPaintDevice::devicePixelRatio":http://qt-project.org/doc/qt-5/qpaintdevice.html#devicePixelRatio.
From the help text: "Returns the device pixel ratio for device.
Common values are 1 for normal-dpi displays and 2 for high-dpi "retina" displays." -
The problem is that high resolution images are not loaded in Stylesheets (.css file) in "retina" display.
-
Here you can find similar "issue":https://bugreports.qt-project.org/browse/QTBUG-36825 in Jira.