Repository navigation
Expand file tree
/
Copy pathhamsystem.cpp
More file actions
67 lines (53 loc) · 1.96 KB
/
Copy pathhamsystem.cpp
File metadata and controls
67 lines (53 loc) · 1.96 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
#include "hamsystem.h"
#include "ui_mainwindow.h"
#include <QIcon>
#include <QDebug>
#include <QVBoxLayout>
void HamSystem::navConnect(int id)
{
QToolButton* btn_changed = btns.at(id);
QToolButton::connect(btn_changed, &QToolButton::clicked, ui->stackedWidget, [=](){
//切换页面
if(ui->stackedWidget->currentIndex() < btns.size())
btns.at(ui->stackedWidget->currentIndex())->setPalette(ui->centralwidget->palette().color(QPalette::Window));
QColor color;
color.setRgb(0xff, 0xa5, 0x00);
QPalette pal = btn_changed->palette();
pal.setColor(QPalette::ButtonText, color);
btn_changed->setPalette(pal);
ui->stackedWidget->setCurrentIndex(id);
});
}
HamSystem::HamSystem(Ui::MainWindow *ui) : ui(ui), tasksControl(ui)
{
btns.append(ui->homeButton);
btns.append(ui->classButton);
btns.append(ui->tasksButton);
btns.append(ui->settingsButton);
//按钮均匀分布
QVBoxLayout *VLayout = new QVBoxLayout;
for(auto& btn : btns)
VLayout->addWidget(btn);
QWidget *widget = new QWidget(ui->tab);
widget->setLayout(VLayout);
widget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
ui->tab->addWidget(widget);
for (int id = 0; id < btns.size(); id++)
{
btns.at(id)->setFixedSize(50, 50);
navConnect(id);
}
ui->buttonBox_2->button(QDialogButtonBox::Ok)->setText("确定");
ui->buttonBox_2->button(QDialogButtonBox::Cancel)->setText("取消");
QDialogButtonBox::connect(ui->buttonBox_2, &QDialogButtonBox::accepted, ui->stackedWidget, [=]{
QColor color;
color.setRgb(0xff, 0xa5, 0x00);
QPalette pal = ui->homeButton->palette();
pal.setColor(QPalette::ButtonText, color);
ui->homeButton->setPalette(pal);
ui->stackedWidget->setCurrentIndex(0);
ui->tab->show();
});//登录
ui->tab->hide();
ui->stackedWidget->setCurrentIndex(btns.size());
}