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
qstylepainter.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// Qt-Security score:significant reason:default
4
5#ifndef QSTYLEPAINTER_H
6#define QSTYLEPAINTER_H
7
8#include <QtWidgets/qtwidgetsglobal.h>
9#include <QtGui/qpainter.h>
10#include <QtWidgets/qstyle.h>
11#include <QtWidgets/qwidget.h>
12
14
15
16class QStylePainter : public QPainter
17{
18public:
19 inline QStylePainter() : QPainter(), widget(nullptr), wstyle(nullptr) {}
20 inline explicit QStylePainter(QWidget *w) { begin(w, w); }
21 inline QStylePainter(QPaintDevice *pd, QWidget *w) { begin(pd, w); }
22 inline bool begin(QWidget *w) { return begin(w, w); }
23 inline bool begin(QPaintDevice *pd, QWidget *w) {
24 Q_ASSERT_X(w, "QStylePainter::QStylePainter", "Widget must be non-zero");
25 widget = w;
26 wstyle = w->style();
27 const bool res = QPainter::begin(pd);
28 setRenderHint(QPainter::SmoothPixmapTransform);
29 return res;
30 }
31 inline void drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &opt);
32 inline void drawControl(QStyle::ControlElement ce, const QStyleOption &opt);
33 inline void drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex &opt);
34 inline void drawItemText(const QRect &r, int flags, const QPalette &pal, bool enabled,
35 const QString &text, QPalette::ColorRole textRole = QPalette::NoRole);
36 inline void drawItemPixmap(const QRect &r, int flags, const QPixmap &pixmap);
37 inline QStyle *style() const { return wstyle; }
38
39private:
40 QWidget *widget;
41 QStyle *wstyle;
43};
44
45void QStylePainter::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &opt)
46{
47 wstyle->drawPrimitive(pe, &opt, this, widget);
48}
49
50void QStylePainter::drawControl(QStyle::ControlElement ce, const QStyleOption &opt)
51{
52 wstyle->drawControl(ce, &opt, this, widget);
53}
54
55void QStylePainter::drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex &opt)
56{
57 wstyle->drawComplexControl(cc, &opt, this, widget);
58}
59
60void QStylePainter::drawItemText(const QRect &r, int flags, const QPalette &pal, bool enabled,
61 const QString &text, QPalette::ColorRole textRole)
62{
63 wstyle->drawItemText(this, r, flags, pal, enabled, text, textRole);
64}
65
66void QStylePainter::drawItemPixmap(const QRect &r, int flags, const QPixmap &pixmap)
67{
68 wstyle->drawItemPixmap(this, r, flags, pixmap);
69}
70
71QT_END_NAMESPACE
72
73#endif // QSTYLEPAINTER_H
The QComboBox widget combines a button with a dropdown list.
Definition qcombobox.h:25
QFileDialogComboBox(QWidget *parent=nullptr)
QStringList history() const
void setHistory(const QStringList &paths)
void setFileDialogPrivate(QFileDialogPrivate *d_pointer)
void showPopup() override
Displays the list of items in the combobox.
void paintEvent(QPaintEvent *) override
\reimp
void keyPressEvent(QKeyEvent *e) override
FIXME: this is a hack to avoid propagating key press events to the dialog and from there to the "Ok" ...
void setFileDialogPrivate(QFileDialogPrivate *d_pointer)
QFileDialogLineEdit(QWidget *parent=nullptr)
void setFileDialogPrivate(QFileDialogPrivate *d_pointer)
QSize sizeHint() const override
QFileDialogListView(QWidget *parent=nullptr)
void keyPressEvent(QKeyEvent *e) override
void keyPressEvent(QKeyEvent *e) override
QSize sizeHint() const override
QFileDialogTreeView(QWidget *parent)
void setFileDialogPrivate(QFileDialogPrivate *d_pointer)
The QFileDialog class provides a dialog that allows users to select files or directories.
Definition qfiledialog.h:29
\inmodule QtWidgets
The QGridLayout class lays out widgets in a grid.
Definition qgridlayout.h:22
The QListView class provides a list or icon view onto a model.
Definition qlistview.h:18
Definition qlist.h:80
\inmodule QtCore
QSideBarDelegate(QWidget *parent=nullptr)
Definition qsidebar_p.h:35
The QStackedWidget class provides a stack of widgets where only one widget is visible at a time.
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
QStylePainter(QPaintDevice *pd, QWidget *w)
Construct a QStylePainter using pd for its paint device, and attributes from widget.
bool begin(QPaintDevice *pd, QWidget *w)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool begin(QWidget *w)
Begin painting operations on the specified widget.
void drawControl(QStyle::ControlElement ce, const QStyleOption &opt)
Use the widget's style to draw a control element ce specified by QStyleOption option.
void drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &opt)
Use the widget's style to draw a primitive element pe specified by QStyleOption option.
QStylePainter()
Constructs a QStylePainter.
void drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex &opt)
Use the widget's style to draw a complex control cc specified by the QStyleOptionComplex option.
void drawItemText(const QRect &r, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole)
Draws the text in rectangle rect and palette pal.
QStyle * style() const
Return the current style used by the QStylePainter.
void drawItemPixmap(const QRect &r, int flags, const QPixmap &pixmap)
Draws the pixmap in rectangle rect.
QStylePainter(QWidget *w)
Construct a QStylePainter using widget widget for its paint device.
The QStyledItemDelegate class provides display and editing facilities for data items from a model.
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition qtoolbutton.h:21
The QTreeView class provides a default model/view implementation of a tree view.
Definition qtreeview.h:21
QT_REQUIRE_CONFIG(animation)
static QUrl _qt_get_directory(const QUrl &url, const QFileInfo &local)
static void _qt_init_lastVisited()
QStringList qt_strip_filters(const QStringList &filters)
QStringList qt_make_filter_list(const QString &filter)
static QString fileFromPath(const QString &rootPath, QString path)
static bool isCaseSensitiveFileSystem(const QString &path)
QT_REQUIRE_CONFIG(filedialog)
QT_REQUIRE_CONFIG(thread)
QT_REQUIRE_CONFIG(treeview)
QFileDialogArgs(const QUrl &url={})