aguayro
4th July 2012, 22:45
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:
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());
}
}
And the results:
7949
this is my paint method:
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());
}
}
And the results:
7949