28 lines
796 B
C++
28 lines
796 B
C++
|
|
#include "imagegallery.h"
|
||
|
|
#include <QPixmap>
|
||
|
|
|
||
|
|
ImageGallery::ImageGallery(QWidget *parent) : QWidget(parent)
|
||
|
|
{
|
||
|
|
scrollArea = new QScrollArea(this);
|
||
|
|
scrollWidget = new QWidget(scrollArea);
|
||
|
|
scrollLayout = new QVBoxLayout(scrollWidget);
|
||
|
|
|
||
|
|
scrollArea->setWidgetResizable(true);
|
||
|
|
scrollArea->setWidget(scrollWidget);
|
||
|
|
|
||
|
|
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||
|
|
mainLayout->addWidget(scrollArea);
|
||
|
|
setLayout(mainLayout);
|
||
|
|
}
|
||
|
|
|
||
|
|
void ImageGallery::addImage(const QString &imagePath)
|
||
|
|
{
|
||
|
|
QLabel *imageLabel = new QLabel(scrollWidget);
|
||
|
|
QPixmap pixmap(imagePath);
|
||
|
|
imageLabel->setPixmap(pixmap.scaledToWidth(400, Qt::SmoothTransformation));
|
||
|
|
imageLabel->setAlignment(Qt::AlignCenter);
|
||
|
|
|
||
|
|
scrollLayout->addWidget(imageLabel);
|
||
|
|
imageLabels.append(imageLabel);
|
||
|
|
}
|