QtBase  v6.3.1
qapplication.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtWidgets module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QAPPLICATION_H
41 #define QAPPLICATION_H
42 
43 #include <QtWidgets/qtwidgetsglobal.h>
44 #include <QtCore/qcoreapplication.h>
45 #include <QtGui/qwindowdefs.h>
46 #include <QtCore/qpoint.h>
47 #include <QtCore/qsize.h>
48 #include <QtGui/qcursor.h>
49 #include <QtGui/qguiapplication.h>
50 
52 
53 
54 class QStyle;
55 class QEventLoop;
56 class QIcon;
57 class QLocale;
59 
60 class QApplication;
62 #if defined(qApp)
63 #undef qApp
64 #endif
65 #define qApp (static_cast<QApplication *>(QCoreApplication::instance()))
66 
67 class Q_WIDGETS_EXPORT QApplication : public QGuiApplication
68 {
69  Q_OBJECT
70  Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime)
71  Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval)
72  Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval)
73 #if QT_CONFIG(wheelevent)
74  Q_PROPERTY(int wheelScrollLines READ wheelScrollLines WRITE setWheelScrollLines)
75 #endif
76  Q_PROPERTY(int startDragTime READ startDragTime WRITE setStartDragTime)
77  Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance)
78 #ifndef QT_NO_STYLE_STYLESHEET
79  Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
80 #endif
81  Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled)
82 
83 public:
84 #ifdef Q_QDOC
85  QApplication(int &argc, char **argv);
86 #else
87  QApplication(int &argc, char **argv, int = ApplicationFlags);
88 #endif
89  virtual ~QApplication();
90 
91  static QStyle *style();
92  static void setStyle(QStyle*);
93  static QStyle *setStyle(const QString&);
94 
96  static QPalette palette(const QWidget *);
97  static QPalette palette(const char *className);
98  static void setPalette(const QPalette &, const char* className = nullptr);
99  static QFont font();
100  static QFont font(const QWidget*);
101  static QFont font(const char *className);
102  static void setFont(const QFont &, const char* className = nullptr);
103 
104 #if QT_DEPRECATED_SINCE(6,0)
105  QT_DEPRECATED_VERSION_X_6_0("Use the QFontMetricsF constructor instead.")
106  static QFontMetrics fontMetrics();
107 #endif
108 
109  static QWidgetList allWidgets();
110  static QWidgetList topLevelWidgets();
111 
112  static QWidget *activePopupWidget();
113  static QWidget *activeModalWidget();
114  static QWidget *focusWidget();
115 
116  static QWidget *activeWindow();
117  static void setActiveWindow(QWidget* act);
118 
119  static QWidget *widgetAt(const QPoint &p);
120  static inline QWidget *widgetAt(int x, int y) { return widgetAt(QPoint(x, y)); }
121  static QWidget *topLevelAt(const QPoint &p);
122  static inline QWidget *topLevelAt(int x, int y) { return topLevelAt(QPoint(x, y)); }
123 
124  static void beep();
125  static void alert(QWidget *widget, int duration = 0);
126 
127  static void setCursorFlashTime(int);
128  static int cursorFlashTime();
129 
130  static void setDoubleClickInterval(int);
131  static int doubleClickInterval();
132 
133  static void setKeyboardInputInterval(int);
134  static int keyboardInputInterval();
135 
136 #if QT_CONFIG(wheelevent)
137  static void setWheelScrollLines(int);
138  static int wheelScrollLines();
139 #endif
140 
141  static void setStartDragTime(int ms);
142  static int startDragTime();
143  static void setStartDragDistance(int l);
144  static int startDragDistance();
145 
146  static bool isEffectEnabled(Qt::UIEffect);
147  static void setEffectEnabled(Qt::UIEffect, bool enable = true);
148 
149  static int exec();
150  bool notify(QObject *, QEvent *) override;
151 
152 #ifdef QT_KEYPAD_NAVIGATION
153  static void setNavigationMode(Qt::NavigationMode mode);
154  static Qt::NavigationMode navigationMode();
155 #endif
156 
158 
159 Q_SIGNALS:
161 
162 public:
163  QString styleSheet() const;
164 public Q_SLOTS:
165 #ifndef QT_NO_STYLE_STYLESHEET
166  void setStyleSheet(const QString& sheet);
167 #endif
168  void setAutoSipEnabled(const bool enabled);
169  bool autoSipEnabled() const;
170  static void closeAllWindows();
171  static void aboutQt();
172 
173 protected:
174  bool event(QEvent *) override;
175  bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) override;
176 
177 private:
179  Q_DECLARE_PRIVATE(QApplication)
180 
181  friend class QGraphicsWidget;
182  friend class QGraphicsItem;
183  friend class QGraphicsScene;
184  friend class QGraphicsScenePrivate;
185  friend class QWidget;
186  friend class QWidgetPrivate;
187  friend class QWidgetWindow;
188  friend class QTranslator;
189  friend class QWidgetAnimator;
190 #ifndef QT_NO_SHORTCUT
191  friend class QShortcut;
192  friend class QLineEdit;
193  friend class QWidgetTextControl;
194 #endif
195  friend class QAction;
196 
197 #ifndef QT_NO_GESTURES
198  friend class QGestureManager;
199 #endif
200 };
201 
203 
204 #endif // QAPPLICATION_H
Arabic default style
Definition: afstyles.h:94
The QAction class provides an abstraction for user commands that can be added to different user inter...
Definition: qaction.h:65
The QApplication class manages the GUI application's control flow and main settings.
Definition: qapplication.h:68
static int cursorFlashTime()
static int startDragTime()
void focusChanged(QWidget *old, QWidget *now)
static QWidget * widgetAt(int x, int y)
Definition: qapplication.h:120
static int startDragDistance()
static QWidget * topLevelAt(int x, int y)
Definition: qapplication.h:122
static int doubleClickInterval()
static int keyboardInputInterval()
friend class QApplication
The QEvent class is the base class of all event classes. Event objects contain event parameters.
Definition: qcoreevent.h:58
The QEventLoop class provides a means of entering and leaving an event loop.
Definition: qeventloop.h:50
The QFont class specifies a query for a font used for drawing text.
Definition: qfont.h:56
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:56
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:83
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
The QGraphicsWidget class is the base class for all widget items in a QGraphicsScene.
The QGuiApplication class manages the GUI application's control flow and main settings.
bool notify(QObject *, QEvent *) override
static QWindow * topLevelAt(const QPoint &pos)
static void setFont(const QFont &)
static QPalette palette()
static void setPalette(const QPalette &pal)
static QFont font()
bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) override
bool event(QEvent *) override
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:56
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:64
The QObject class is the base class of all Qt objects.
Definition: qobject.h:125
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:55
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:52
Definition: qthread_p.h:98
The QShortcut class is used to create keyboard shortcuts.
Definition: qshortcut.h:55
The QString class provides a Unicode character string.
Definition: qstring.h:388
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition: qstyle.h:65
The QTranslator class provides internationalization support for text output.
Definition: qtranslator.h:55
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:133
QOpenGLWidget * widget
[1]
fontMetrics
qApp setStyleSheet("QPushButton { color: white }")
[21]
std::chrono::milliseconds ms
NavigationMode
Definition: qnamespace.h:1676
UIEffect
Definition: qnamespace.h:1166
#define QT_DEPRECATED_VERSION_X_6_0(text)
Definition: qglobal.h:444
#define Q_DISABLE_COPY(Class)
Definition: qglobal.h:515
#define QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(T)
GLint GLint GLint GLint GLint x
[0]
GLenum mode
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLboolean enable
GLint y
GLfloat GLfloat p
[1]
Definition: qopenglext.h:12698
#define Q_PROPERTY(...)
Definition: qtmetamacros.h:92
#define Q_OBJECT
Definition: qtmetamacros.h:158
#define Q_SLOTS
Definition: qtmetamacros.h:80
#define Q_SIGNALS
Definition: qtmetamacros.h:81
const char className[16]
[1]
Definition: qwizard.cpp:135
widget setStyle(proxy)