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