diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/styles/qproxystyle.cpp | 27 | ||||
-rw-r--r-- | src/widgets/styles/qproxystyle.h | 3 |
2 files changed, 25 insertions, 5 deletions
diff --git a/src/widgets/styles/qproxystyle.cpp b/src/widgets/styles/qproxystyle.cpp index 66ace0f60b..911223cae2 100644 --- a/src/widgets/styles/qproxystyle.cpp +++ b/src/widgets/styles/qproxystyle.cpp @@ -108,10 +108,9 @@ void QProxyStylePrivate::ensureBaseStyle() const } /*! - Constructs a QProxyStyle object for overriding behavior in \a style - or in the current application \l{QStyle}{style} if \a style is 0 - (default). Normally \a style is 0, because you want to override - behavior in the system style. + Constructs a QProxyStyle object for overriding behavior in the + specified base \a style, or in the current \l{QApplication::style} + {application style} if base \a style is not specified. Ownership of \a style is transferred to QProxyStyle. */ @@ -127,6 +126,26 @@ QProxyStyle::QProxyStyle(QStyle *style) : } /*! + Constructs a QProxyStyle object for overriding behavior in + the base style specified by style \a key, or in the current + \l{QApplication::style}{application style} if the specified + style \a key is unrecognized. + + \sa QStyleFactory::create() +*/ +QProxyStyle::QProxyStyle(const QString &key) : + QCommonStyle(*new QProxyStylePrivate()) +{ + Q_D(QProxyStyle); + QStyle *style = QStyleFactory::create(key); + if (style) { + d->baseStyle = style; + style->setProxy(this); + style->setParent(this); // Take ownership + } +} + +/*! Destroys the QProxyStyle object. */ QProxyStyle::~QProxyStyle() diff --git a/src/widgets/styles/qproxystyle.h b/src/widgets/styles/qproxystyle.h index 62a263b520..d1623c745c 100644 --- a/src/widgets/styles/qproxystyle.h +++ b/src/widgets/styles/qproxystyle.h @@ -55,7 +55,8 @@ class Q_WIDGETS_EXPORT QProxyStyle : public QCommonStyle Q_OBJECT public: - QProxyStyle(QStyle *baseStyle = 0); + QProxyStyle(QStyle *style = 0); + QProxyStyle(const QString &key); ~QProxyStyle(); QStyle *baseStyle() const; |