-
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: