QLabel 圖檔大小設定
QVariant var= index.model()->data(index,Qt::DisplayRole);
QString strStempJpgPath = var.toString();
QPixmap pixmap(strStempJpgPath);
//int width=pixmap.width();
//int height=pixmap.height();
/* For example, if you have code like
pixmap.resize(size);
you can rewrite it as
pixmap = pixmap.copy(QRect(QPoint(0, 0), size));
*/
//pixmap = pixmap.copy(QRect(QPoint(10, 10), size)); //圖檔去掉邊緣
//将圖檔的寬和高都縮放,并且在給定的矩形内保持寬高的比值
pixmap = pixmap.scaled(option.rect.width(),option.rect.height(),Qt::KeepAspectRatio);
painter->drawPixmap(option.rect.x(),option.rect.y(),pixmap);
break;