-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathLineEdit.h
35 lines (31 loc) · 850 Bytes
/
LineEdit.h
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
#pragma once
#include <QFrame>
#include <QMainWindow>
#include <QLineEdit>
namespace Examples {
class Window1 : public QMainWindow {
Q_OBJECT
public:
Window1() {
lineEdit1.setText("line edit");
lineEdit1.move(10, 10);
connect(&lineEdit1, &QLineEdit::textChanged, [&] {
if (lineEdit2.text() != lineEdit1.text())
lineEdit2.setText(lineEdit1.text());
});
lineEdit2.setText("lineEdit");
lineEdit2.move(10, 50);
connect(&lineEdit2, &QLineEdit::textChanged, [&] {
if (lineEdit1.text() != lineEdit2.text())
lineEdit1.setText(lineEdit2.text());
});
setCentralWidget(&frame);
setWindowTitle("Line edit example");
resize(300, 300);
}
private:
QFrame frame;
QLineEdit lineEdit1 {&frame};
QLineEdit lineEdit2 {&frame};
};
}