-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathLine.h
More file actions
48 lines (39 loc) · 1.29 KB
/
Line.h
File metadata and controls
48 lines (39 loc) · 1.29 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
#include <QApplication>
#include <QFrame>
#include <QLineEdit>
#include <QMainWindow>
namespace Examples {
class ColoredLine : public QFrame {
Q_OBJECT
public:
ColoredLine(QWidget* parent = nullptr) : QFrame(parent) {setAutoFillBackground(true);}
QColor color() const {return palette().color(QPalette::Window);}
void setColor(const QColor& color) {return setPalette(color);}
};
class Window1 : public QMainWindow {
Q_OBJECT
public:
Window1() {
lineSeparator.setGeometry(10, 10, 280, 2);
lineSeparator.setColor(qApp->palette().color(QPalette::Base));
lineRed.setGeometry(10, 20, 2, 250);
lineRed.setColor(Qt::GlobalColor::red);
lineGreen.setGeometry(149, 20, 2, 250);
lineGreen.setColor(Qt::GlobalColor::darkGreen);
lineBlue.setGeometry(288, 20, 2, 250);
lineBlue.setColor(Qt::GlobalColor::blue);
lineSeparator2.setGeometry(10, 278, 280, 2);
lineSeparator2.setColor(qApp->palette().color(QPalette::Text));
setCentralWidget(&frame);
setWindowTitle("Lines example");
resize(300, 300);
}
private:
QFrame frame;
ColoredLine lineSeparator{&frame};
ColoredLine lineRed{&frame};
ColoredLine lineGreen{&frame};
ColoredLine lineBlue{&frame};
ColoredLine lineSeparator2{&frame};
};
}