-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem02.cpp
More file actions
38 lines (27 loc) · 1023 Bytes
/
Copy pathproblem02.cpp
File metadata and controls
38 lines (27 loc) · 1023 Bytes
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
#include <QApplication>
#include <QWidget>
#include <QPushButton>
#include <QHBoxLayout>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
auto *window = new QWidget;
window->setWindowTitle("Problem #2");
window->resize(500, 500);
auto *canvas = new QWidget(window);
canvas->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
auto *toolbar = new QWidget(window);
auto *redButton = new QPushButton("Red", toolbar);
auto *greenButton = new QPushButton("Green", toolbar);
auto *blueButton = new QPushButton("Blue", toolbar);
auto *buttonLayout = new QHBoxLayout(toolbar);
buttonLayout->addWidget(redButton);
buttonLayout->addWidget(greenButton);
buttonLayout->addWidget(blueButton);
toolbar->setLayout(buttonLayout);
auto *mainLayout = new QVBoxLayout(window);
mainLayout->addWidget(canvas);
mainLayout->addWidget(toolbar);
window->setLayout(mainLayout);
window->show();
return QApplication::exec();
}