PySide6.QtWidgets.QProxyStyle¶
- class QProxyStyle¶
- The - QProxyStyleclass is a convenience class that simplifies dynamically overriding- QStyleelements. More…- Synopsis¶- Methods¶- def - __init__()
- def - baseStyle()
- def - setBaseStyle()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - A - QProxyStylewraps 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: - from textedit import * from PySide6.QtWidgets import QApplication from PySide6.QtWidgets import QProxyStyle class MyProxyStyle(QProxyStyle): # public int styleHint(StyleHint hint, QStyleOption option = None, widget = None, QStyleHintReturn returnData = None) override() if hint == QStyle.SH_UnderlineShortcut: return 0 return QProxyStyle.styleHint(hint, option, widget, returnData) if __name__ == "__main__": Q_INIT_RESOURCE(textedit) a = QApplication(argc, argv) a.setStyle(MyProxyStyle()) mw = TextEdit() mw.resize(700, 800) mw.show() #... - Warning: The - common stylesprovided by Qt will respect this hint, because they call- proxy(), but there is no guarantee that- 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 - style(). You have to create a separate custom style for the widget similar to:- ... proxy = MyProxyStyle(QApplication.style().name()) proxy.setParent(widget) # take ownership to avoid memleak widget.setStyle(proxy) ... - See also - Constructs a - QProxyStyleobject for overriding behavior in the specified- style, or in the default native- styleif- styleis not specified.- Ownership of - styleis transferred to- QProxyStyle.- __init__(key)
- Parameters:
- key – str 
 
 - Constructs a - QProxyStyleobject for overriding behavior in the base style specified by style- key, or in the current- application styleif the specified style- keyis unrecognized.- See also - Returns the proxy base style object. If no base style is set on the proxy style, - QProxyStylewill create an instance of the application style instead.- See also - Sets the base style that should be proxied. - Ownership of - styleis transferred to- QProxyStyle.- If style is - None, a desktop-dependent style will be assigned automatically.- See also