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
4#ifndef QSTYLEPAINTER_H
5#define QSTYLEPAINTER_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtGui/qpainter.h>
9#include <QtWidgets/qstyle.h>
10#include <QtWidgets/qwidget.h>
11
13
14
15class QStylePainter : public QPainter
16{
17public:
18 inline QStylePainter() : QPainter(), widget(nullptr), wstyle(nullptr) {}
19 inline explicit QStylePainter(QWidget *w) { begin(w, w); }
20 inline QStylePainter(QPaintDevice *pd, QWidget *w) { begin(pd, w); }
21 inline bool begin(QWidget *w) { return begin(w, w); }
22 inline bool begin(QPaintDevice *pd, QWidget *w) {
23 Q_ASSERT_X(w, "QStylePainter::QStylePainter", "Widget must be non-zero");
24 widget = w;
25 wstyle = w->style();
26 const bool res = QPainter::begin(pd);
27 setRenderHint(QPainter::SmoothPixmapTransform);
28 return res;
29 }
30 inline void drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &opt);
31 inline void drawControl(QStyle::ControlElement ce, const QStyleOption &opt);
32 inline void drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex &opt);
33 inline void drawItemText(const QRect &r, int flags, const QPalette &pal, bool enabled,
34 const QString &text, QPalette::ColorRole textRole = QPalette::NoRole);
35 inline void drawItemPixmap(const QRect &r, int flags, const QPixmap &pixmap);
36 inline QStyle *style() const { return wstyle; }
37
38private:
39 QWidget *widget;
40 QStyle *wstyle;
42};
43
44void QStylePainter::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &opt)
45{
46 wstyle->drawPrimitive(pe, &opt, this, widget);
47}
48
49void QStylePainter::drawControl(QStyle::ControlElement ce, const QStyleOption &opt)
50{
51 wstyle->drawControl(ce, &opt, this, widget);
52}
53
54void QStylePainter::drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex &opt)
55{
56 wstyle->drawComplexControl(cc, &opt, this, widget);
57}
58
59void QStylePainter::drawItemText(const QRect &r, int flags, const QPalette &pal, bool enabled,
60 const QString &text, QPalette::ColorRole textRole)
61{
62 wstyle->drawItemText(this, r, flags, pal, enabled, text, textRole);
63}
64
65void QStylePainter::drawItemPixmap(const QRect &r, int flags, const QPixmap &pixmap)
66{
67 wstyle->drawItemPixmap(this, r, flags, pixmap);
68}
69
70QT_END_NAMESPACE
71
72#endif // QSTYLEPAINTER_H
The QComboBox widget combines a button with a dropdown list.
Definition qcombobox.h:24
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:28
\inmodule QtWidgets
The QGridLayout class lays out widgets in a grid.
Definition qgridlayout.h:21
The QListView class provides a list or icon view onto a model.
Definition qlistview.h:17
Definition qlist.h:76
\inmodule QtCore
QSideBarDelegate(QWidget *parent=nullptr)
Definition qsidebar_p.h:34
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:20
The QTreeView class provides a default model/view implementation of a tree view.
Definition qtreeview.h:20
Combined button and popup list for selecting options.
QT_REQUIRE_CONFIG(animation)
static QUrl _qt_get_directory(const QUrl &url, const QFileInfo &local)
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(itemmodel)
QT_REQUIRE_CONFIG(treeview)
QFileDialogArgs(const QUrl &url={})