QProxyStyle¶
The
QProxyStyle
class is a convenience class that simplifies dynamically overridingQStyle
elements. More…
Synopsis¶
Functions¶
def
baseStyle
()def
setBaseStyle
(style)
Detailed Description¶
A
QProxyStyle
wraps aQStyle
(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:
#include "textedit.h" #include <QApplication> #include <QProxyStyle> class MyProxyStyle : public QProxyStyle { public: int styleHint(StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override { if (hint == QStyle::SH_UnderlineShortcut) return 0; return QProxyStyle::styleHint(hint, option, widget, returnData); } }; int main(int argc, char **argv) { Q_INIT_RESOURCE(textedit); QApplication a(argc, argv); a.setStyle(new MyProxyStyle); TextEdit mw; mw.resize(700, 800); mw.show(); //... }Warning: The
common styles
provided by Qt will respect this hint, because they callproxy()
, but there is no guarantee thatproxy()
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.See also
- class PySide2.QtWidgets.QProxyStyle([style=None])¶
PySide2.QtWidgets.QProxyStyle(key)
- param style:
- param key:
str
Constructs a
QProxyStyle
object for overriding behavior in the specifiedstyle
, or in the default nativestyle
ifstyle
is not specified.Ownership of
style
is transferred toQProxyStyle
.
- PySide2.QtWidgets.QProxyStyle.baseStyle()¶
- Return type:
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.See also
- PySide2.QtWidgets.QProxyStyle.setBaseStyle(style)¶
- Parameters:
style –
PySide2.QtWidgets.QStyle
Sets the base style that should be proxied.
Ownership of
style
is transferred toQProxyStyle
.If style is
None
, a desktop-dependent style will be assigned automatically.See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.