Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
|
The QProxyStyle class is a convenience class that simplifies dynamically overriding QStyle elements. More...
#include <qproxystyle.h>
Public Member Functions | |
QProxyStyle (QStyle *style=nullptr) | |
Constructs a QProxyStyle object for overriding behavior in the specified style, or in the default native \l{QApplication::style()} {style} if style is not specified. | |
QProxyStyle (const QString &key) | |
Constructs a QProxyStyle object for overriding behavior in the base style specified by style key, or in the current \l{QApplication::style()}{application style} if the specified style key is unrecognized. | |
~QProxyStyle () | |
Destroys the QProxyStyle object. | |
QStyle * | baseStyle () const |
Returns the proxy base style object. | |
void | setBaseStyle (QStyle *style) |
Sets the base style that should be proxied. | |
void | drawPrimitive (PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=nullptr) const override |
\reimp | |
void | drawControl (ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=nullptr) const override |
\reimp | |
void | drawComplexControl (ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget=nullptr) const override |
\reimp | |
void | drawItemText (QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const override |
\reimp | |
virtual void | drawItemPixmap (QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override |
\reimp | |
QSize | sizeFromContents (ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override |
\reimp | |
QRect | subElementRect (SubElement element, const QStyleOption *option, const QWidget *widget) const override |
\reimp | |
QRect | subControlRect (ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override |
\reimp | |
QRect | itemTextRect (const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const override |
\reimp | |
QRect | itemPixmapRect (const QRect &r, int flags, const QPixmap &pixmap) const override |
\reimp | |
SubControl | hitTestComplexControl (ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget=nullptr) const override |
\reimp | |
int | styleHint (StyleHint hint, const QStyleOption *option=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const override |
\reimp | |
int | pixelMetric (PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override |
\reimp | |
int | layoutSpacing (QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override |
This slot is called by layoutSpacing() to determine the spacing that should be used between control1 and control2 in a layout. | |
QIcon | standardIcon (StandardPixmap standardIcon, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override |
Returns an icon for the given standardIcon. | |
QPixmap | standardPixmap (StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=nullptr) const override |
\reimp | |
QPixmap | generatedIconPixmap (QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const override |
\reimp | |
QPalette | standardPalette () const override |
\reimp | |
void | polish (QWidget *widget) override |
\reimp | |
void | polish (QPalette &pal) override |
\reimp | |
void | polish (QApplication *app) override |
\reimp | |
void | unpolish (QWidget *widget) override |
\reimp | |
void | unpolish (QApplication *app) override |
\reimp | |
Public Member Functions inherited from QCommonStyle | |
QCommonStyle () | |
Constructs a QCommonStyle. | |
~QCommonStyle () | |
Destroys the style. | |
Public Member Functions inherited from QStyle | |
QStyle () | |
Constructs a style object. | |
virtual | ~QStyle () |
Destroys the style object. | |
QString | name () const |
Returns the name of the style. | |
int | combinedLayoutSpacing (QSizePolicy::ControlTypes controls1, QSizePolicy::ControlTypes controls2, Qt::Orientation orientation, QStyleOption *option=nullptr, QWidget *widget=nullptr) const |
const QStyle * | proxy () const |
Public Member Functions inherited from QObject | |
Q_INVOKABLE | QObject (QObject *parent=nullptr) |
Constructs an object with parent object parent. | |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. | |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
Filters events if this object has been installed as an event filter for the watched object. | |
QString | objectName () const |
Q_WEAK_OVERLOAD void | setObjectName (const QString &name) |
Sets the object's name to name. | |
void | setObjectName (QAnyStringView name) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QBindable< QString > | bindableObjectName () |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false . | |
bool | isWindowType () const |
Returns true if the object is a window; otherwise returns false . | |
bool | isQuickItemType () const |
Returns true if the object is a QQuickItem; otherwise returns false . | |
bool | signalsBlocked () const noexcept |
Returns true if signals are blocked; otherwise returns false . | |
bool | blockSignals (bool b) noexcept |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). | |
QThread * | thread () const |
Returns the thread in which the object lives. | |
bool | moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL) |
Changes the thread affinity for this object and its children and returns true on success. | |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds. | |
int | startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
void | killTimer (int id) |
Kills the timer with timer identifier, id. | |
void | killTimer (Qt::TimerId id) |
template<typename T > | |
T | findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object. | |
template<typename T > | |
QList< T > | findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. | |
template<typename T > | |
T | findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename T > | |
QList< T > | findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
const QObjectList & | children () const |
Returns a list of child objects. | |
void | setParent (QObject *parent) |
Makes the object a child of parent. | |
void | installEventFilter (QObject *filterObj) |
Installs an event filter filterObj on this object. | |
void | removeEventFilter (QObject *obj) |
Removes an event filter object obj from this object. | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const |
bool | disconnect (const QObject *receiver, const char *member=nullptr) const |
void | dumpObjectTree () const |
Dumps a tree of children to the debug output. | |
void | dumpObjectInfo () const |
Dumps information about signal connections, etc. | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. | |
bool | setProperty (const char *name, QVariant &&value) |
QVariant | property (const char *name) const |
Returns the value of the object's name property. | |
QList< QByteArray > | dynamicPropertyNames () const |
QBindingStorage * | bindingStorage () |
const QBindingStorage * | bindingStorage () const |
QObject * | parent () const |
Returns a pointer to the parent object. | |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false . | |
Protected Member Functions | |
bool | event (QEvent *e) override |
\reimp | |
Protected Member Functions inherited from QCommonStyle | |
QCommonStyle (QCommonStylePrivate &dd) | |
Protected Member Functions inherited from QStyle | |
QStyle (QStylePrivate &dd) | |
Protected Member Functions inherited from QObject | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr. | |
int | senderSignalIndex () const |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. | |
bool | isSignalConnected (const QMetaMethod &signal) const |
virtual void | timerEvent (QTimerEvent *event) |
This event handler can be reimplemented in a subclass to receive timer events for the object. | |
virtual void | childEvent (QChildEvent *event) |
This event handler can be reimplemented in a subclass to receive child events. | |
virtual void | customEvent (QEvent *event) |
This event handler can be reimplemented in a subclass to receive custom events. | |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
QObject (QObjectPrivate &dd, QObject *parent=nullptr) | |
The QProxyStyle class is a convenience class that simplifies dynamically overriding QStyle elements.
\inmodule QtWidgets
A QProxyStyle wraps a QStyle (usually the default system style) for the purpose of dynamically overriding painting or other specific style behavior.
The following example shows how to override the shortcut underline behavior on any platform:
Warning: The \l {QCommonStyle} {common styles} provided by Qt will respect this hint, because they call QStyle::proxy(), but there is no guarantee that QStyle::proxy() will be called for user defined or system controlled styles. It would not work on a Mac, for example, where menus are handled by the operating system.
When a proxy style should be set on a specific widget only, you have to make sure to not set the proxy on the global application style which is returned by QWidget::style(). You have to create a separate custom style for the widget similar to:
Definition at line 16 of file qproxystyle.h.
Constructs a QProxyStyle object for overriding behavior in the specified style, or in the default native \l{QApplication::style()} {style} if style is not specified.
Ownership of style is transferred to QProxyStyle.
Definition at line 88 of file qproxystyle.cpp.
References d, and QObject::setParent().
QProxyStyle::QProxyStyle | ( | const QString & | key | ) |
Constructs a QProxyStyle object for overriding behavior in the base style specified by style key, or in the current \l{QApplication::style()}{application style} if the specified style key is unrecognized.
Definition at line 107 of file qproxystyle.cpp.
QProxyStyle::~QProxyStyle | ( | ) |
Destroys the QProxyStyle object.
Definition at line 115 of file qproxystyle.cpp.
QStyle * QProxyStyle::baseStyle | ( | ) | const |
Returns the proxy base style object.
If no base style is set on the proxy style, QProxyStyle will create an instance of the application style instead.
Definition at line 126 of file qproxystyle.cpp.
References d.
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
\reimp
Reimplemented from QCommonStyle.
Definition at line 158 of file qproxystyle.cpp.
References d, painter, and widget.
Referenced by CustomStyle::drawPrimitive().
|
overrideprotectedvirtual |
\reimp
Reimplemented from QObject.
Definition at line 349 of file qproxystyle.cpp.
References d, QObject::event(), QEvent::FocusIn, QEvent::FocusOut, QCoreApplication::sendEvent(), and QEvent::type().
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
This slot is called by layoutSpacing() to determine the spacing that should be used between control1 and control2 in a layout.
orientation specifies whether the controls are laid out side by side or stacked vertically. The option parameter can be used to pass extra information about the parent widget. The widget parameter is optional and can also be used if option is \nullptr.
The default implementation returns -1.
Reimplemented from QCommonStyle.
Definition at line 395 of file qproxystyle.cpp.
|
overridevirtual |
|
overridevirtual |
\reimp
Reimplemented from QCommonStyle.
Definition at line 313 of file qproxystyle.cpp.
References d.
Sets the base style that should be proxied.
Ownership of style is transferred to QProxyStyle.
If style is \nullptr, a desktop-dependent style will be assigned automatically.
Definition at line 141 of file qproxystyle.cpp.
References d.
|
overridevirtual |
|
overridevirtual |
Returns an icon for the given standardIcon.
Reimplement this slot to provide your own icons in a QStyle subclass. The option argument can be used to pass extra information required to find the appropriate icon. The widget argument is optional and can also be used to help find the icon.
Reimplemented from QCommonStyle.
Definition at line 374 of file qproxystyle.cpp.
References d, standardIcon(), and widget.
Referenced by standardIcon().
|
overridevirtual |
|
overridevirtual |
\reimp
Reimplemented from QCommonStyle.
Definition at line 277 of file qproxystyle.cpp.
References d, opt, standardPixmap(), and widget.
Referenced by standardPixmap().
|
overridevirtual |
\reimp
Reimplemented from QCommonStyle.
Definition at line 259 of file qproxystyle.cpp.
References d, hint(), and widget.
Referenced by MyProxyStyle::styleHint().
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |