-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
50 lines (35 loc) · 966 Bytes
/
mainwindow.cpp
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
#include <QMessageBox>
#include <QVBoxLayout>
#include "mainwindow.h"
#include "TColorPicker.h"
TMainWindow::TMainWindow(QWidget *parent) :
QMainWindow(parent)
{
CreateUI();
}
TMainWindow::~TMainWindow()
{
}
void TMainWindow::CreateUI()
{
mColorPicker = new TColorPicker(this);
mColorPicker->resize(50, 50);
QWidget* widget = new QWidget(this);
setCentralWidget(widget);
QVBoxLayout* layout = new QVBoxLayout(widget);
widget->setLayout(layout);
layout->addWidget(mColorPicker);
mLable = new QLabel(tr("xxx Sample"), this);
layout->addWidget(mLable);
QPushButton* pushButton = new QPushButton("testingText", this);
layout->addWidget(pushButton);
connect(mColorPicker, SIGNAL(clicked()), this, SLOT(onColorChange()));
}
void TMainWindow::onColorChange()
{
QColor color = mColorPicker->GetColor(Qt::black, QPoint(0, 0));
if (color.isValid())
{
mLable->setStyleSheet(QString("color:%1; font-size:22px;").arg(color.name()));
}
}