-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinputnode.cpp
More file actions
52 lines (43 loc) · 1.52 KB
/
inputnode.cpp
File metadata and controls
52 lines (43 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "inputnode.h"
InputNode::InputNode(QWidget *parent)
: QWidget(parent)
{
// Create layouts
mainLayout = new QVBoxLayout(this);
// Create title label
titleLabel = new QLabel("Input Image", this);
titleLabel->setAlignment(Qt::AlignCenter);
// Create image label
imageLabel = new QLabel(this);
imageLabel->setAlignment(Qt::AlignCenter);
imageLabel->setMinimumSize(200, 150);
imageLabel->setStyleSheet("border: 1px solid gray;");
// Create browse button
browseButton = new QPushButton("Browse...", this);
// Add widgets to layout
mainLayout->addWidget(titleLabel);
mainLayout->addWidget(imageLabel);
mainLayout->addWidget(browseButton);
// Connections
connect(browseButton, &QPushButton::clicked, this, &InputNode::browseImage);
}
void InputNode::browseImage()
{
QString filePath = QFileDialog::getOpenFileName(this,
"Select Input Image",
QDir::homePath(),
"Images (*.png *.jpg *.jpeg *.bmp)");
if (!filePath.isEmpty()) {
input_file = filePath;
QPixmap pixmap(filePath);
if (!pixmap.isNull()) {
imageLabel->setPixmap(pixmap.scaled(imageLabel->size(),
Qt::KeepAspectRatio, Qt::SmoothTransformation));
emit fileChanged(filePath);
}
}
}
QString InputNode::getFilePath() const
{
return input_file;
}