内容表

上一话题

QProgressDialog

下一话题

QPushButton

QProxyStyle

QProxyStyle class is a convenience class that simplifies dynamically overriding QStyle 元素。 更多

Inheritance diagram of PySide2.QtWidgets.QProxyStyle

概要

函数

详细描述

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:

#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 常见 styles provided 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.

另请参阅

QStyle

class QProxyStyle ( [ style=None ] )

QProxyStyle(key)

param style

QStyle

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 ( )
返回类型

QStyle

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.

另请参阅

baseStyle()