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
src_gui_kernel_qguiapplication.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#include <QApplication>
4#include <QMessageBox>
5#include <QSessionManager>
6#include <QWidget>
7
9struct MyMainWidget : public QWidget
10{
13 bool saveDocument() { return true; };
16};
18void do_something(QString command) { Q_UNUSED(command); };
20
22int main(int argc, char *argv[])
23{
25 QApplication app(argc, argv);
26 // ...
27 return app.exec();
28}
30
31
39
41{
42 if (manager.allowsInteraction()) {
45 tr("My Application"),
46 tr("Save changes to document?"),
48
49 switch (ret) {
51 manager.release();
52 if (!saveDocument())
53 manager.cancel();
54 break;
56 break;
58 default:
59 manager.cancel();
60 }
61 } else {
62 // we did not get permission to interact, then
63 // do something reasonable instead
64 }
65}
67
68
69/* wrap snippet 2
70
72appname -session id
74
75*/ // wrap snippet 2
76
77} // src_gui_kernel_qguiapplication
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 commitDataRequest(QSessionManager &sessionManager)
static void setDesktopSettingsAware(bool on)
Sets whether Qt should use the system's standard colors, fonts, etc., to on.
static StandardButton warning(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
The QSessionManager class provides access to the session manager.
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
int main()
[0]
MyMainWidget mySession(nullptr)
QList< QString > QStringList
Constructs a string list that contains the given string, str.
#define qApp
return ret
#define tr(X)
#define Q_UNUSED(x)
do_something()
QApplication app(argc, argv)
[0]
QNetworkAccessManager manager