Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QToolbar High-resolution (high dpi)
asdfjkl last edited by
I am trying to optimize an application for high - resolution displays. In order to simulate this, I set the DPI setting on Windows 10 higher than normal, so that I have a devicePixelRatio of 2.
I am loading high resolution SVG images, render them to a QPixmap, and set these as QIcons on the Toolbar. For that I need the iconSize information of the toolbar.
However the toolbar reports its IconSize way too small, so that there are large borders around the image.
I guess a picture says more than 1000 words: Left (sharp but borders) is done by rendering to proper size taking toolbar-iconSize info into account, on the right is just creating a QIcon directly from the SVG
For the left case (sharp, but borders around the icon) I am creating the Icons like this:
ImageSize = toolbar.IconSize()
const qreal PixelRatio = this->devicePixelRatio();
QPixmap img = new QPixmap(ImageSizePixelRatio);
for the right (blurry, but no borders) case I am just doing