File indexing completed on 2026-06-14 08:33:19
0001
0002
0003
0004
0005 #ifndef QAPPLICATION_H
0006 #define QAPPLICATION_H
0007
0008 #include <QtWidgets/qtwidgetsglobal.h>
0009 #include <QtCore/qcoreapplication.h>
0010 #include <QtGui/qwindowdefs.h>
0011 #include <QtCore/qpoint.h>
0012 #include <QtCore/qsize.h>
0013 #include <QtGui/qcursor.h>
0014 #include <QtGui/qguiapplication.h>
0015
0016 QT_BEGIN_NAMESPACE
0017
0018
0019 class QStyle;
0020 class QEventLoop;
0021 class QIcon;
0022 class QLocale;
0023 class QPlatformNativeInterface;
0024
0025 class QApplication;
0026 class QApplicationPrivate;
0027 #if defined(qApp)
0028 #undef qApp
0029 #endif
0030 #define qApp (static_cast<QApplication *>(QCoreApplication::instance()))
0031
0032 class Q_WIDGETS_EXPORT QApplication : public QGuiApplication
0033 {
0034 Q_OBJECT
0035 Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime)
0036 Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval)
0037 Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval)
0038 #if QT_CONFIG(wheelevent)
0039 Q_PROPERTY(int wheelScrollLines READ wheelScrollLines WRITE setWheelScrollLines)
0040 #endif
0041 Q_PROPERTY(int startDragTime READ startDragTime WRITE setStartDragTime)
0042 Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance)
0043 #ifndef QT_NO_STYLE_STYLESHEET
0044 Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
0045 #endif
0046 Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled)
0047
0048 public:
0049 #ifdef Q_QDOC
0050 QApplication(int &argc, char **argv);
0051 #else
0052 QApplication(int &argc, char **argv, int = ApplicationFlags);
0053 #endif
0054 virtual ~QApplication();
0055
0056 static QStyle *style();
0057 static void setStyle(QStyle*);
0058 static QStyle *setStyle(const QString&);
0059
0060 using QGuiApplication::palette;
0061 static QPalette palette(const QWidget *);
0062 static QPalette palette(const char *className);
0063 static void setPalette(const QPalette &, const char* className = nullptr);
0064 static QFont font();
0065 static QFont font(const QWidget*);
0066 static QFont font(const char *className);
0067 static void setFont(const QFont &, const char* className = nullptr);
0068
0069 #if QT_DEPRECATED_SINCE(6,0)
0070 QT_DEPRECATED_VERSION_X_6_0("Use QFontMetricsF(qApp->font()) instead.")
0071 static QFontMetrics fontMetrics();
0072 #endif
0073
0074 static QWidgetList allWidgets();
0075 static QWidgetList topLevelWidgets();
0076
0077 static QWidget *activePopupWidget();
0078 static QWidget *activeModalWidget();
0079 static QWidget *focusWidget();
0080
0081 static QWidget *activeWindow();
0082
0083 #if QT_DEPRECATED_SINCE(6, 5)
0084 QT_DEPRECATED_VERSION_X_6_5("Use QWidget::activateWindow() instead.")
0085 static void setActiveWindow(QWidget* act);
0086 #endif
0087
0088 static QWidget *widgetAt(const QPoint &p);
0089 static inline QWidget *widgetAt(int x, int y) { return widgetAt(QPoint(x, y)); }
0090 static QWidget *topLevelAt(const QPoint &p);
0091 static inline QWidget *topLevelAt(int x, int y) { return topLevelAt(QPoint(x, y)); }
0092
0093 static void beep();
0094 static void alert(QWidget *widget, int duration = 0);
0095
0096 static void setCursorFlashTime(int);
0097 static int cursorFlashTime();
0098
0099 static void setDoubleClickInterval(int);
0100 static int doubleClickInterval();
0101
0102 static void setKeyboardInputInterval(int);
0103 static int keyboardInputInterval();
0104
0105 #if QT_CONFIG(wheelevent)
0106 static void setWheelScrollLines(int);
0107 static int wheelScrollLines();
0108 #endif
0109
0110 static void setStartDragTime(int ms);
0111 static int startDragTime();
0112 static void setStartDragDistance(int l);
0113 static int startDragDistance();
0114
0115 static bool isEffectEnabled(Qt::UIEffect);
0116 static void setEffectEnabled(Qt::UIEffect, bool enable = true);
0117
0118 static int exec();
0119 bool notify(QObject *, QEvent *) override;
0120
0121 #ifdef QT_KEYPAD_NAVIGATION
0122 static void setNavigationMode(Qt::NavigationMode mode);
0123 static Qt::NavigationMode navigationMode();
0124 #endif
0125
0126 QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QApplication)
0127
0128 Q_SIGNALS:
0129 void focusChanged(QWidget *old, QWidget *now);
0130
0131 public:
0132 QString styleSheet() const;
0133 bool autoSipEnabled() const;
0134 public Q_SLOTS:
0135 #ifndef QT_NO_STYLE_STYLESHEET
0136 void setStyleSheet(const QString& sheet);
0137 #endif
0138 void setAutoSipEnabled(const bool enabled);
0139 static void closeAllWindows();
0140 static void aboutQt();
0141
0142 protected:
0143 bool event(QEvent *) override;
0144 # if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
0145 QT_DEPRECATED_VERSION_X_6_10("This feature will be removed in Qt 7")
0146 bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) override;
0147 # endif
0148
0149 private:
0150 Q_DISABLE_COPY(QApplication)
0151 Q_DECLARE_PRIVATE(QApplication)
0152
0153 friend class QGraphicsWidget;
0154 friend class QGraphicsItem;
0155 friend class QGraphicsScene;
0156 friend class QGraphicsScenePrivate;
0157 friend class QWidget;
0158 friend class QWidgetPrivate;
0159 friend class QWidgetWindow;
0160 friend class QTranslator;
0161 friend class QWidgetAnimator;
0162 #ifndef QT_NO_SHORTCUT
0163 friend class QShortcut;
0164 friend class QLineEdit;
0165 friend class QWidgetTextControl;
0166 #endif
0167 friend class QAction;
0168
0169 #ifndef QT_NO_GESTURES
0170 friend class QGestureManager;
0171 #endif
0172 };
0173
0174 QT_END_NAMESPACE
0175
0176 #endif