summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qproxystyle.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2012-11-27 00:06:14 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-04 14:54:57 +0100
commit14dab5b2d7cb7b6b32d9672758c0f3b5d4ec3354 (patch)
tree8206805908b2c9da0edd6619845a0019cc5d95d2 /src/widgets/styles/qproxystyle.cpp
parent4b7276b93f21e4b131c8840ca2f6c6bf4f003595 (diff)
Add QProxyStyle(QString key) constructor for convenience
The QStyle implementations are becoming private, so the following slightly verbose pattern seems to be now repeated a lot: new QProxyStyle(QStyleFactory::create("windows")) This change adds an alternative, more convenient constructor for this particular use case: new QProxyStyle("windows") Change-Id: I97ded597a0fd3225a6354ebea0abb367237430af Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/widgets/styles/qproxystyle.cpp')
-rw-r--r--src/widgets/styles/qproxystyle.cpp27
1 files changed, 23 insertions, 4 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()