-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
62 lines (46 loc) · 1.38 KB
/
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
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "mainwindow.h"
#include <QVBoxLayout>
#include <QLineEdit>
#include <QPushButton>
#include <QApplication>
#include <QTimer>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QWidget * widget_ = new QWidget;
QVBoxLayout * layout_ = new QVBoxLayout(this);
widget_->setLayout(layout_);
QLineEdit *
edit_ = new QLineEdit;
layout_->addWidget(edit_);
edit_ = new QLineEdit;
layout_->addWidget(edit_);
QLineEdit *
edit_3 = new QLineEdit;
layout_->addWidget(edit_3);
QLineEdit *
edit_4 = new QLineEdit;
layout_->addWidget(edit_4);
setCentralWidget(widget_);
QPushButton * button_ = new QPushButton("open window");
layout_->addWidget(button_);
connect(button_, &QPushButton::clicked, [=]{
QMainWindow * window_ = new QMainWindow;
connect(qApp, &QApplication::aboutToQuit, window_, &QMainWindow::deleteLater);
QWidget * widget_ = new QWidget;
widget_->setLayout(new QVBoxLayout);
QPushButton * button_ = new QPushButton("set focus");
widget_->layout()->addWidget(button_);
window_->setCentralWidget(widget_);
window_->show();
QTimer::singleShot(2000, [=]{
edit_4->setFocus();
});
connect(button_, &QPushButton::clicked, [=]{
edit_3->setFocus();
});
});
}
MainWindow::~MainWindow()
{
}