-
Bug
-
Resolution: Fixed
-
P2: Important
-
5.9.7, 5.12.0
-
None
-
-
e771e5e2d (dev), 82b3f3fba (6.7), a09661402 (tqtc/lts-6.5)
When using an Icon in the decoration role of a QTableView it does not render properly. It appears to render a different size than the intended one. Which is especially visible for something like the check mark from the apply button icon. When using a pixmap though for the appropriate size, the icon is rendered correctly.
A simple example:
class Model : public QAbstractTableModel { int rowCount(const QModelIndex &parent = QModelIndex()) const override { return 1; } int columnCount(const QModelIndex &parent = QModelIndex()) const override { return 2; } QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override { if( role == Qt::DecorationRole ) { QIcon icon = QApplication::desktop()->style()->standardIcon( QStyle::SP_DialogApplyButton ); switch( index.column() ) { case 0: return icon; case 1: return icon.pixmap(QSize(16, 16)); } } return QVariant(); } };
Then simply set the model:
ui->tableView->setIconSize(QSize(16, 16));
ui->tableView->setModel(new Model());
As seen on the image below:
For Gerrit Dashboard: QTBUG-73655 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
562299,2 | QCommonStyle: fix drawing artifacts for some standard icons | dev | qt/qtbase | Status: MERGED | +2 | 0 |
562610,2 | QCommonStyle: fix drawing artifacts for some standard icons | 6.7 | qt/qtbase | Status: MERGED | +2 | 0 |
562686,2 | QCommonStyle: fix drawing artifacts for some standard icons | tqtc/lts-6.5 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |
652820,1 | Re-sample the 16x16 icon for the standard apply button | dev | qt/qtbase | Status: ABANDONED | 0 | 0 |