Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QApplication>
5#include <QPushButton>
6#include <QFileInfo>
7#include <QDir>
8#include <QGroupBox>
9#include <QVBoxLayout>
10#include <QDebug>
11
12int main(int argc, char *argv[])
13{
14 QApplication app(argc, argv);
15
17 QFileInfo fileInfo1("~/examples/191697/.");
18 QFileInfo fileInfo2("~/examples/191697/..");
19 QFileInfo fileInfo3("~/examples/191697/main.cpp");
22 QFileInfo fileInfo4(".");
23 QFileInfo fileInfo5("..");
24 QFileInfo fileInfo6("main.cpp");
26
27 qDebug() << fileInfo1.fileName();
28 qDebug() << fileInfo2.fileName();
29 qDebug() << fileInfo3.fileName();
30 qDebug() << fileInfo4.fileName();
31 qDebug() << fileInfo5.fileName();
32 qDebug() << fileInfo6.fileName();
33
34 QGroupBox *groupBox = new QGroupBox(QStringLiteral("QFileInfo::dir() test"));
35
37
38 QPushButton* button1 = new QPushButton(fileInfo1.dir().path());
39 QPushButton* button2 = new QPushButton(fileInfo2.dir().path());
40 QPushButton* button3 = new QPushButton(fileInfo3.dir().path());
41 QPushButton* button4 = new QPushButton(fileInfo4.dir().path());
42 QPushButton* button5 = new QPushButton(fileInfo5.dir().path());
43 QPushButton* button6 = new QPushButton(fileInfo6.dir().path());
44 vbox->addWidget(button1);
45 vbox->addWidget(button2);
46 vbox->addWidget(button3);
47 vbox->addWidget(button4);
48 vbox->addWidget(button5);
49 vbox->addWidget(button6);
50 vbox->addStretch(1);
51
52 groupBox->show();
53
54 return app.exec();
55}
The QApplication class manages the GUI application's control flow and main settings.
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment.
void addStretch(int stretch=0)
Adds a stretchable space (a QSpacerItem) with zero minimum size and stretch factor stretch to the end...
The QGroupBox widget provides a group box frame with a title.
Definition qgroupbox.h:17
The QPushButton widget provides a command button.
Definition qpushbutton.h:20
The QVBoxLayout class lines up widgets vertically.
Definition qboxlayout.h:91
void show()
Shows the widget and its child widgets.
Definition qwidget.cpp:7875
QPushButton
[1]
int main()
[0]
#define qDebug
[1]
Definition qlogging.h:164
#define QStringLiteral(str)
QApplication app(argc, argv)
[0]
QVBoxLayout * vbox