Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qapplication.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QAPPLICATION_H
5#define QAPPLICATION_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtCore/qcoreapplication.h>
9#include <QtGui/qwindowdefs.h>
10#include <QtCore/qpoint.h>
11#include <QtCore/qsize.h>
12#include <QtGui/qcursor.h>
13#include <QtGui/qguiapplication.h>
14
15QT_BEGIN_NAMESPACE
16
17
18class QStyle;
19class QEventLoop;
20class QIcon;
21class QLocale;
22class QPlatformNativeInterface;
23
24class QApplication;
25class QApplicationPrivate;
26#if defined(qApp)
27#undef qApp
28#endif
29#define qApp (static_cast<QApplication *>(QCoreApplication::instance()))
30
31class Q_WIDGETS_EXPORT QApplication : public QGuiApplication
32{
33 Q_OBJECT
34 Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime)
35 Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval)
36 Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval)
37#if QT_CONFIG(wheelevent)
38 Q_PROPERTY(int wheelScrollLines READ wheelScrollLines WRITE setWheelScrollLines)
39#endif
40 Q_PROPERTY(int startDragTime READ startDragTime WRITE setStartDragTime)
41 Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance)
42#ifndef QT_NO_STYLE_STYLESHEET
43 Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
44#endif
45 Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled)
46
47public:
48#ifdef Q_QDOC
49 QApplication(int &argc, char **argv);
50#else
51 QApplication(int &argc, char **argv, int = ApplicationFlags);
52#endif
53 virtual ~QApplication();
54
55 static QStyle *style();
56 static void setStyle(QStyle*);
57 static QStyle *setStyle(const QString&);
58
59 using QGuiApplication::palette;
60 static QPalette palette(const QWidget *);
61 static QPalette palette(const char *className);
62 static void setPalette(const QPalette &, const char* className = nullptr);
63 static QFont font();
64 static QFont font(const QWidget*);
65 static QFont font(const char *className);
66 static void setFont(const QFont &, const char* className = nullptr);
67
68#if QT_DEPRECATED_SINCE(6,0)
69 QT_DEPRECATED_VERSION_X_6_0("Use the QFontMetricsF constructor instead.")
70 static QFontMetrics fontMetrics();
71#endif
72
73 static QWidgetList allWidgets();
74 static QWidgetList topLevelWidgets();
75
76 static QWidget *activePopupWidget();
77 static QWidget *activeModalWidget();
78 static QWidget *focusWidget();
79
80 static QWidget *activeWindow();
81
82#if QT_DEPRECATED_SINCE(6, 5)
83 QT_DEPRECATED_VERSION_X_6_5("Use QWidget::activateWindow() instead.")
84 static void setActiveWindow(QWidget* act);
85#endif
86
87 static QWidget *widgetAt(const QPoint &p);
88 static inline QWidget *widgetAt(int x, int y) { return widgetAt(QPoint(x, y)); }
89 static QWidget *topLevelAt(const QPoint &p);
90 static inline QWidget *topLevelAt(int x, int y) { return topLevelAt(QPoint(x, y)); }
91
92 static void beep();
93 static void alert(QWidget *widget, int duration = 0);
94
95 static void setCursorFlashTime(int);
96 static int cursorFlashTime();
97
98 static void setDoubleClickInterval(int);
99 static int doubleClickInterval();
100
101 static void setKeyboardInputInterval(int);
102 static int keyboardInputInterval();
103
104#if QT_CONFIG(wheelevent)
105 static void setWheelScrollLines(int);
106 static int wheelScrollLines();
107#endif
108
109 static void setStartDragTime(int ms);
110 static int startDragTime();
111 static void setStartDragDistance(int l);
112 static int startDragDistance();
113
114 static bool isEffectEnabled(Qt::UIEffect);
115 static void setEffectEnabled(Qt::UIEffect, bool enable = true);
116
117 static int exec();
118 bool notify(QObject *, QEvent *) override;
119
120#ifdef QT_KEYPAD_NAVIGATION
121 static void setNavigationMode(Qt::NavigationMode mode);
122 static Qt::NavigationMode navigationMode();
123#endif
124
125 QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QApplication)
126
127Q_SIGNALS:
128 void focusChanged(QWidget *old, QWidget *now);
129
130public:
131 QString styleSheet() const;
132 bool autoSipEnabled() const;
133public Q_SLOTS:
134#ifndef QT_NO_STYLE_STYLESHEET
135 void setStyleSheet(const QString& sheet);
136#endif
137 void setAutoSipEnabled(const bool enabled);
138 static void closeAllWindows();
139 static void aboutQt();
140
141protected:
142 bool event(QEvent *) override;
143 bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) override;
144
145private:
146 Q_DISABLE_COPY(QApplication)
147 Q_DECLARE_PRIVATE(QApplication)
148
149 friend class QGraphicsWidget;
150 friend class QGraphicsItem;
151 friend class QGraphicsScene;
152 friend class QGraphicsScenePrivate;
153 friend class QWidget;
154 friend class QWidgetPrivate;
155 friend class QWidgetWindow;
156 friend class QTranslator;
157 friend class QWidgetAnimator;
158#ifndef QT_NO_SHORTCUT
159 friend class QShortcut;
160 friend class QLineEdit;
161 friend class QWidgetTextControl;
162#endif
163 friend class QAction;
164
165#ifndef QT_NO_GESTURES
166 friend class QGestureManager;
167#endif
168};
169
170QT_END_NAMESPACE
171
172#endif // QAPPLICATION_H
The QApplication class manages the GUI application's control flow and main settings.
QScopedPointer< QImageIOHandlerPrivate > d_ptr
The QPaintEngineState class provides information about the active paint engine's current state....
\inmodule QtGui
virtual QPixmap createPixmap(QSize size)
friend class QPainter
void setSystemRect(const QRect &rect)
void setActive(bool newState)
Sets the active state of the paint engine to state.
virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual QPixmap createPixmapFromImage(QImage image, Qt::ImageConversionFlags flags=Qt::AutoColor)
friend class QWidgetPrivate
QRect systemRect() const
QPaintEngine(PaintEngineFeatures features=PaintEngineFeatures())
Creates a paint engine with the featureset specified by caps.
friend class QFontEngineQPF2
friend class QMacCGContext
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.
virtual void drawLines(const QLineF *lines, int lineCount)
The default implementation splits the list of lines in lines into lineCount separate calls to drawPat...
PolygonDrawMode
\value OddEvenMode The polygon should be drawn using OddEven fill rule.
virtual void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the buffer points.
virtual void drawRects(const QRectF *rects, int rectCount)
Draws the first rectCount rectangles in the buffer rects.
virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)
Reimplement this function to draw the part of the image specified by the sr rectangle in the given re...
QPainter * painter() const
Returns the paint engine's painter.
void fix_neg_rect(int *x, int *y, int *w, int *h)
void setPaintDevice(QPaintDevice *device)
virtual QPoint coordinateOffset() const
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
Reimplement this virtual function to draw the polygon defined by the pointCount first points in point...
void setDirty(DirtyFlags df)
void setSystemClip(const QRegion &baseClip)
QPaintEngineState * state
friend class QPainterReplayer
friend class QX11GLPlatformPixmap
PaintEngineFeatures gccaps
void clearDirty(DirtyFlags df)
bool hasFeature(PaintEngineFeatures feature) const
Returns true if the paint engine supports the specified feature; otherwise returns false.
virtual void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect.
QRegion systemClip() const
bool isExtended() const
QPaintDevice * paintDevice() const
Returns the device that this engine is painting on, if painting is active; otherwise returns \nullptr...
bool testDirty(DirtyFlags df)
virtual void updateState(const QPaintEngineState &state)=0
Reimplement this function to update the state of a paint engine.
DirtyFlag
\value DirtyPen The pen is dirty and needs to be updated.
Type
\value X11 \value Windows \value MacPrinter \value CoreGraphics \macos's Quartz2D (CoreGraphics) \val...
virtual Type type() const =0
Reimplement this function to return the paint engine \l{Type}.
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling.
bool begin(QPaintDevice *)
Begins painting the paint device and returns true if successful; otherwise returns false.
void drawRects(const QRectF *rects, int rectCount)
Draws the first rectCount of the given rectangles using the current pen and brush.
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
friend class QFontEngineMac
Definition qpainter.h:425
friend class QWin32PaintEngine
Definition qpainter.h:430
friend class QWin32PaintEnginePrivate
Definition qpainter.h:431
friend class QWidget
Definition qpainter.h:421
friend class QFontEngineWin
Definition qpainter.h:426
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
bool end()
Ends painting.
void drawPoints(const QPointF *points, int pointCount)
Draws the first pointCount points in the array points using the current pen's color.
bool isActive() const
Returns true if begin() has been called and end() has not yet been called; otherwise returns false.
\inmodule QtCore\reentrant
Definition qpoint.h:217
The QPolygonF class provides a list of points using floating point precision.
Definition qpolygon.h:96
Internal QTextItem.
\inmodule QtGui
uint is_closing
Definition qwidget.h:82
QPalette pal
Definition qwidget.h:91
uint focus_policy
Definition qwidget.h:80
uint in_show
Definition qwidget.h:83
uint unused
Definition qwidget.h:89
uint fstrut_dirty
Definition qwidget.h:85
QRect wrect
Definition qwidget.h:93
QRect crect
Definition qwidget.h:90
uint in_destructor
Definition qwidget.h:88
uint sizehint_forced
Definition qwidget.h:81
uint in_set_window_state
Definition qwidget.h:84
Qt::WindowFlags window_flags
Definition qwidget.h:78
QFont fnt
Definition qwidget.h:92
uint window_modality
Definition qwidget.h:87
uint window_state
Definition qwidget.h:79
WId winid
Definition qwidget.h:76
uint context_menu_policy
Definition qwidget.h:86
uint widget_attributes
Definition qwidget.h:77
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
The QWindows11Style class provides a look and feel suitable for applications on Microsoft Windows 11.
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override
void unpolish(QWidget *widget) override
void polish(QWidget *widget) override
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const override
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override
QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const override
QWindows11Style(QWindows11StylePrivate &dd)
void polish(QPalette &pal) override
int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
int styleHint(StyleHint hint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const override
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override
QRect subElementRect(QStyle::SubElement element, const QStyleOption *option, const QWidget *widget=nullptr) const override
~QWindows11Style() override
Destructor.
HRGN mask(QWidget *widget)
QWindowsThemeData(const QWidget *w=nullptr, QPainter *p=nullptr, int themeIn=-1, int part=0, int state=0, const QRect &r=QRect())
QMarginsF margins(const QRect &rect, int propId=TMT_CONTENTMARGINS)
const QWidget * widget
static RECT toRECT(const QRect &qr)
QMarginsF margins(int propId=TMT_CONTENTMARGINS)
static QSizeF themeSize(const QWidget *w=nullptr, QPainter *p=nullptr, int themeIn=-1, int part=0, int state=0)
HBITMAP buffer(int w=0, int h=0)
static int fixedPixelMetric(QStyle::PixelMetric pm)
static HDC hdcForWidgetBackingStore(const QWidget *widget)
static QBackingStore * backingStoreForWidget(const QWidget *widget)
bool swapAlphaChannel(const QRect &rect, bool allPixels=false)
bool drawBackgroundThruNativeBuffer(QWindowsThemeData &QWindowsThemeData, qreal aditionalDevicePixelRatio, qreal correctionFactor)
static HWND winId(const QWidget *widget)
void init(bool force=false)
static bool isLineEditBaseColorSet(const QStyleOption *option, const QWidget *widget)
bool drawBackgroundDirectly(HDC dc, QWindowsThemeData &QWindowsThemeData, qreal aditionalDevicePixelRatio)
static bool isItemViewDelegateLineEdit(const QWidget *widget)
static bool useVista(bool update=false)
bool fixAlphaChannel(const QRect &rect)
void cleanup(bool force=false)
bool isTransparent(QWindowsThemeData &QWindowsThemeData)
bool hasAlphaChannel(const QRect &rect)
QRegion region(QWindowsThemeData &QWindowsThemeData)
bool drawBackground(QWindowsThemeData &QWindowsThemeData, qreal correctionFactor=1)
static HTHEME createTheme(int theme, const QWidget *widget)
static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option=nullptr, const QWidget *widget=nullptr)
static QString themeName(int theme)
The QWindowsVistaStyle class provides a look and feel suitable for applications on Microsoft Windows ...
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const override
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override
int styleHint(StyleHint hint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const override
SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget=nullptr) const override
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override
void polish(QWidget *widget) override
int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=nullptr) const override
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
\reimp
~QWindowsVistaStyle() override
Destructor.
void polish(QPalette &pal) override
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=nullptr) const override
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override
QWindowsVistaStyle(QWindowsVistaStylePrivate &dd)
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const override
void unpolish(QWidget *widget) override
Combined button and popup list for selecting options.
Q_DECLARE_TYPEINFO(QByteArrayView, Q_PRIMITIVE_TYPE)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2439
bool operator==(const ThemeMapKey &k1, const ThemeMapKey &k2)
@ UnknownAlpha
size_t qHash(const ThemeMapKey &key)
AlphaChannelType alphaType
ThemeMapKey(const QWindowsThemeData &data)
ThemeMapKey()=default