Details
-
Bug
-
Resolution: Won't Do
-
P2: Important
-
None
-
5.3.2, 5.4.0, 5.6.0
-
Windows 8.1, Mac OS X 10.9.5.
Description
When a QIcon is supplied with a QPixmap with devicePixelRatio higher than 1, the icon is not painted at the right size at all time.
Build and run the following code:
#include <QtWidgets> int main(int argc, char *argv[]) { QApplication a(argc, argv); QPixmap iconPix(50, 50); iconPix.fill(Qt::transparent); QPainter painter(&iconPix); painter.setBrush(Qt::red); painter.setPen(Qt::transparent); painter.setRenderHint(QPainter::Antialiasing); painter.drawEllipse(iconPix.rect()); iconPix.setDevicePixelRatio(2); QIcon icon; iconPix.setDevicePixelRatio(2); icon.addPixmap(iconPix); QWidget w; auto layout = new QVBoxLayout; w.setLayout(layout); layout->addWidget(new QLabel("Icon pixmap: 50x50@2X")); auto btn = new QToolButton; btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); btn->setIcon(icon); btn->setIconSize(QSize(64,64)); btn->setText("Icon size: 64x64"); layout->addWidget(btn); btn = new QToolButton; btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); btn->setIcon(icon); btn->setIconSize(QSize(32,32)); btn->setText("Icon size: 32x32"); layout->addWidget(btn); w.show(); return a.exec(); }
The first tool button has the icon sized correctly when the requested icon size (64x64) is larger than the pixmap pixel size (50x50). But the layout in the button is really messed up.
The second tool button with the same icon has the icon filling up the whole requested size (32X32), which is still larger than the supposed layout size of the icon (25x25).
It seems that the icon ignores the devicePixelRatio when the requested size is smaller than the pixmap pixel size.
See the attached screenshot for reference.
Attachments
Issue Links
- relates to
-
QTBUG-55623 QSystemTrayIcon balloon window needs smooth rendering on high-resolution screens
- Reported
-
QTBUG-75824 QIcon ignores high DPI setting on pixmaps
- Closed
-
QTBUG-49283 Support large custom icons for the system tray balloon notification.
- Closed
For Gerrit Dashboard: QTBUG-44486 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
106852,1 | QIcon: Reset devicePixelRatio to 1 on pixmap add | 5.5 | qt/qtbase | Status: ABANDONED | 0 | 0 |