`
qimo601
  • 浏览: 3416227 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

QLabel 图片大小设定

    博客分类:
  • Qt
阅读更多

 

 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;  
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics