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
<QtGui>
int main(
int argc,
char **argv) {
QApplication app(argc, argv);
QLabel* label =
new QLabel();
label-> setWindowFlags(Qt::FramelessWindowHint);
label->setTextFormat(Qt::RichText);
label->setText(
"<img src=
\"
alert.png
\"
> ALERT !");
QFont* font =
new QFont(
"Courier New");
font->setItalic(
true);
font->setPixelSize(
30);
label->setFont(*font);
label->show();
return app.exec();
}
|
Output : ![]() |
相关热门文章
给主人留下些什么吧!~~
评论热议