Files
Kallery/imagegallery.cpp

28 lines
796 B
C++
Raw Normal View History

2025-02-19 15:23:20 +01:00
#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);
}