Home > Back-end >  Load images in QLabel
Load images in QLabel

Time:11-02

How to show more number(folder) of images in Qlabel or QScrollArea?

QImage image("E:/Raul/Images");
  ui.label->setPixmap(QPixmap::fromImage(image));

Like this but i want more number images will load in one label.

CodePudding user response:

Result:

enter image description here

Code:

#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 is not a web browser, therefore hyperlinks like <img src=/media/cc0-images/grapefruit-slice-332-332.jpg/> doesn't work, but why images from resources can not do it))).

  • Related