hi, i'm trying to make a custom delegate for a QTableView, the image is displayed, but is ugly because it's streched to the cell size, there is anyway to avoid that? just show the image with normal scale inside the cell.
this is my paint method:
int rate = index.data(Qt::DisplayRole).toInt();
if(rate > 0) {
painter->drawPixmap(option.rect, *star, star->rect());
}
}
void rating_delegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
int rate = index.data(Qt::DisplayRole).toInt();
if(rate > 0) {
QPixmap *star = new QPixmap(QString("Skin/%1/Sys/rate%2.png").arg(CurrentSkin).arg(rate));
painter->drawPixmap(option.rect, *star, star->rect());
}
}
To copy to clipboard, switch view to plain text mode
And the results:
6gliskDRKj-b27SF_mMn.png
Bookmarks