[英]Load images in QLabel
如何在 Qlabel 或 QScrollArea 中显示更多数量(文件夹)的图像?
QImage image("E:/Raul/Images");
ui.label->setPixmap(QPixmap::fromImage(image));
像这样,但我希望在一个标签中加载更多数量的图像。
结果:
代码:
#include <QApplication>
#include <QLabel>
#include <QLineEdit>
#include <QPointer>
#include <QPushButton>
#include <QVBoxLayout>
#include <QWizardPage>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget widget;
QVBoxLayout *layout=new QVBoxLayout();
QLabel *label=new QLabel("<img src=:/0_0.jpg align=middle><img src=:/0_1.jpg align=middle><strong>Hello</strong> "
"<font color=red>Sai Raul!");
layout->addWidget(label);
widget.setLayout(layout);
widget.show();
return a.exec();
//
}
QLabel
不是网络浏览器,因此像<img src=/media/cc0-images/grapefruit-slice-332-332.jpg/>
这样的超链接不起作用,但为什么来自资源的图像不能这样做)))。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.