Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Commit 11761b3

Browse files
author
mttwc
committed
Demonstrates vertical box layout
1 parent 82f71ac commit 11761b3

File tree

6 files changed

+46
-40
lines changed

6 files changed

+46
-40
lines changed

HelloQt.pro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
QT += widgets
77

88
SOURCES = src/main.cpp \
9-
src/simple_menu_demonstration.cpp \
9+
src/vertical_box_demonstration.cpp \
1010

11-
HEADERS = src/simple_menu_demonstration.h
11+
HEADERS = src/vertical_box_demonstration.h
1212

1313
CONFIG -= app_bundle
1414

src/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#include <QApplication>
22
#include <QWidget>
3-
#include "simple_menu_demonstration.h"
3+
#include "vertical_box_demonstration.h"
44

55
int main(int argc, char *argv[])
66
{
77
QApplication app(argc, argv);
88

9-
SimpleMenuDemonstration window;
9+
VerticalBoxDemonstration window;
1010

1111
window.resize(250, 150);
12-
window.setWindowTitle("SimpleMenu Demonstration");
12+
window.setWindowTitle("VerticalBox Demonstration");
1313
window.show();
1414

1515
return app.exec();

src/simple_menu_demonstration.cpp

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/simple_menu_demonstration.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/vertical_box_demonstration.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <QVBoxLayout>
2+
#include <QPushButton>
3+
#include "vertical_box_demonstration.h"
4+
5+
VerticalBoxDemonstration::VerticalBoxDemonstration(QWidget *parent)
6+
: QWidget(parent)
7+
{
8+
QVBoxLayout *vbox = new QVBoxLayout(this);
9+
vbox->setSpacing(1);
10+
11+
QPushButton *settings = new QPushButton("Settings", this);
12+
settings->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
13+
QPushButton *accounts = new QPushButton("Accounts", this);
14+
accounts->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
15+
QPushButton *loans = new QPushButton("Loans", this);
16+
loans->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
17+
QPushButton *cash = new QPushButton("Cash", this);
18+
cash->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
19+
QPushButton *debts = new QPushButton("Debts", this);
20+
debts->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
21+
22+
vbox->addWidget(settings);
23+
vbox->addWidget(accounts);
24+
vbox->addWidget(loans);
25+
vbox->addWidget(cash);
26+
vbox->addWidget(debts);
27+
28+
setLayout(vbox);
29+
}

src/vertical_box_demonstration.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef VERTICAL_BOX_DEMONSTRATION_H
2+
#define VERTICAL_BOX_DEMONSTRATION_H
3+
4+
#include <QWidget>
5+
6+
class VerticalBoxDemonstration : public QWidget
7+
{
8+
public:
9+
VerticalBoxDemonstration(QWidget *parent = 0);
10+
};
11+
12+
#endif

0 commit comments

Comments
 (0)