Chinaunix首页 | 论坛 | 博客
  • 博客访问: 336657
  • 博文数量: 135
  • 博客积分: 4637
  • 博客等级: 上校
  • 技术积分: 1410
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-21 13:22
文章分类

全部博文(135)

文章存档

2013年(12)

2012年(14)

2011年(42)

2010年(22)

2009年(18)

2008年(27)

分类: LINUX

2012-07-25 17:05:46

Summary : This code shows how to add image to QLabel.Inserting image inside QLabel text involves setting TextFormat to RichText and adding image tag with required values.
#include
int main(int argc, char **argv) {
 QApplication app(argc, argv); 
 QLabel* label = new QLabel(); 
 label-> setWindowFlags(Qt::FramelessWindowHint); 
 label->setTextFormat(Qt::RichText); 
 label->setText("\"alert.png\"> ALERT !"); 
 QFont* font = new QFont("Courier New"); 
 font->setItalic(true); 
 font->setPixelSize(30);
 label->setFont(*font); 
 label->show(); 
 return app.exec(); 
}
Output : 
QLabel Add Icon ,QLabel Add Image
阅读(596) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~