QProxyStyleclass is a convenience class that simplifies dynamically overridingQStyle元素。 更多 …
def
baseStyle
()
def
setBaseStyle
(style)
A
QProxyStylewraps 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
常见 stylesprovided 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.另请参阅
QProxyStyle
(
[
style=None
]
)
¶
QProxyStyle(key)
- param style
- param key
unicode
构造
QProxyStyle
object for overriding behavior in the specified
style
, or in the default native
style
if
style
is not specified.
Ownership of
style
is transferred to
QProxyStyle
.
PySide2.QtWidgets.QProxyStyle.
baseStyle
(
)
¶
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.
另请参阅
PySide2.QtWidgets.QProxyStyle.
setBaseStyle
(
style
)
¶
style
–
QStyle
Sets the base style that should be proxied.
Ownership of
style
is transferred to
QProxyStyle
.
If style is
None
, a desktop-dependent style will be assigned automatically.
另请参阅