QIcon::pixmap() returns image double the size requested
-
I'm doing this to get images from an icon theme:
QSize iconSize(16, 16); QIcon themeIcon = QIcon::fromTheme("name"); QIcon icon; icon.addPixmap(themeIcon.pixmap(iconSize)); return icon; qDebug() << themeIcon.pixmap(iconSize); // size is 32x32 qDebug() << icon.pixmap(iconSize); // size is 16x16
The SVG file is
16x16
, debug confirmsiconSize
is16x16
, but debug says the pixmap from the icon is32x32
, and at Hdpi (2x)64x64
.Why is this happening?
When using QSvgRenderer I get the results I assumed I should be getting...
16x16
(1x) and32x32
(2x). -
Can you please show some code which is working instead just some lines which don't make any sense?
-
Load one of the project examples in Qt Creator and with an icon theme, just get the pixmap from it, the size is double what I give.
QSize iconSize(16, 16); QIcon themeIcon = QIcon::fromTheme("name"); // Adding pixmap from theme icon to new icon QIcon icon; icon.addPixmap(themeIcon.pixmap(iconSize)); return icon; // What I see in debug qDebug() << themeIcon.pixmap(iconSize); // size is 32x32 qDebug() << icon.pixmap(iconSize); // size is 16x16
-
I still don't see where you call what. Please provide some code which is actually compilable so we can see what you're trying to do.
-
I still don't see where you call what. Please provide some code which is actually compilable so we can see what you're trying to do.
@Christian-Ehrlicher Then please download this project: https://github.com/DougBeney/Qt5-Icon-Themes-Example.
Add these lines to main.cpp:
QSize iconSize(16, 16); QPixmap img = QIcon::fromTheme("folder-alt").pixmap(iconSize); qDebug() << img;
And this to qrc:
<file>icons/zafiro/places/16/folder-alt.svg</file>
-
@Christian-Ehrlicher Then please download this project: https://github.com/DougBeney/Qt5-Icon-Themes-Example.
Add these lines to main.cpp:
QSize iconSize(16, 16); QPixmap img = QIcon::fromTheme("folder-alt").pixmap(iconSize); qDebug() << img;
And this to qrc:
<file>icons/zafiro/places/16/folder-alt.svg</file>