`
qimo601
  • 浏览: 3417360 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
QLabel调整图片大小 qt
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;
Global site tag (gtag.js) - Google Analytics