-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterface.cpp
More file actions
87 lines (70 loc) · 2.47 KB
/
Interface.cpp
File metadata and controls
87 lines (70 loc) · 2.47 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "Interface.h"
#include <QVBoxLayout>
#include <QPushButton>
Interface::Interface(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
// 创建布局
QVBoxLayout* mainLayout = new QVBoxLayout(this);
// 创建一个 QComboBox 来显示所有可用波段
bandComboBox = new QComboBox(this);
for (int i = 1; i <= bandCount; i++) {
QString band = "Band " + QString::number(i);
bandComboBox->addItem(band);
}
// 添加下拉框到主布局中
mainLayout->addWidget(new QLabel("Select Band:"));
mainLayout->addWidget(bandComboBox);
// 创建标签来显示选择的红色、绿色和蓝色波段
redLabel = new QLabel("Red Band: None", this);
greenLabel = new QLabel("Green Band: None", this);
blueLabel = new QLabel("Blue Band: None", this);
// 添加标签到主布局中
mainLayout->addWidget(redLabel);
mainLayout->addWidget(greenLabel);
mainLayout->addWidget(blueLabel);
// 创建按钮用于设置红色、绿色和蓝色波段
QPushButton* setRedButton = new QPushButton("Set as Red Band", this);
QPushButton* setGreenButton = new QPushButton("Set as Green Band", this);
QPushButton* setBlueButton = new QPushButton("Set as Blue Band", this);
// 添加按钮到主布局中
mainLayout->addWidget(setRedButton);
mainLayout->addWidget(setGreenButton);
mainLayout->addWidget(setBlueButton);
// 连接按钮的 clicked 信号到相应的槽函数
connect(setRedButton, SIGNAL(clicked()) , this, SLOT(setRedBand()));
connect(setGreenButton, SIGNAL(clicked()), this, SLOT(setGreenBand()));
connect(setBlueButton, SIGNAL(clicked()), this, SLOT(setBlueBand()));
// 设置主布局
setLayout(mainLayout);
}
Interface::~Interface()
{}
// 槽函数,用于更新红色波段
void Interface::setRedBand() {
// 获取当前选择的波段
int index = bandComboBox->currentIndex();
// 更新红色波段索引
selectedRedBandIndex = index;
// 更新标签
redLabel->setText("Red Band: " + bandComboBox->itemText(index));
}
// 槽函数,用于更新绿色波段
void Interface::setGreenBand() {
// 获取当前选择的波段
int index = bandComboBox->currentIndex();
// 更新绿色波段索引
selectedGreenBandIndex = index;
// 更新标签
greenLabel->setText("Green Band: " + bandComboBox->itemText(index));
}
// 槽函数,用于更新蓝色波段
void Interface::setBlueBand() {
// 获取当前选择的波段
int index = bandComboBox->currentIndex();
// 更新蓝色波段索引
selectedBlueBandIndex = index;
// 更新标签
blueLabel->setText("Blue Band: " + bandComboBox->itemText(index));
}