first version
This commit is contained in:
27
imagegallery.cpp
Normal file
27
imagegallery.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user