diff options
author | Jens Bache-Wiig <jbache@trolltech.com> | 2009-06-12 14:53:40 (GMT) |
---|---|---|
committer | Jens Bache-Wiig <jbache@trolltech.com> | 2009-06-12 15:05:11 (GMT) |
commit | 4d0cc0b9600f8530bb0e8712b4bb109d1810c4a7 (patch) | |
tree | 766d2cbcad6082f794217000778b46ac8d2a7890 /src/gui/styles/qstyle.cpp | |
parent | 56b93b836f70e121540e8d8da9447f5dc6e1fdd6 (diff) | |
download | Qt-4d0cc0b9600f8530bb0e8712b4bb109d1810c4a7.zip Qt-4d0cc0b9600f8530bb0e8712b4bb109d1810c4a7.tar.gz Qt-4d0cc0b9600f8530bb0e8712b4bb109d1810c4a7.tar.bz2 |
Integrating QProxyStyle
This class adds convenient support for proxy styles in Qt.
Note that to support proper proxying, styles now
call their functions through proxy() so that the proxy regains control
over subcomponents. Note that there is a small price to be payed
by the extra function call which can at the cost of readability
be redirected to the private class member in the future.
Task-number: 229556
Reviewed-by: trond
Diffstat (limited to 'src/gui/styles/qstyle.cpp')
-rw-r--r-- | src/gui/styles/qstyle.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/gui/styles/qstyle.cpp b/src/gui/styles/qstyle.cpp index 3fab682..c0fdc83 100644 --- a/src/gui/styles/qstyle.cpp +++ b/src/gui/styles/qstyle.cpp @@ -325,9 +325,10 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C QStyle::QStyle() : QObject(*new QStylePrivate) { + Q_D(QStyle); + d->proxyStyle = this; } - /*! \internal @@ -336,6 +337,8 @@ QStyle::QStyle() QStyle::QStyle(QStylePrivate &dd) : QObject(dd) { + Q_D(QStyle); + d->proxyStyle = this; } /*! @@ -2444,4 +2447,33 @@ QDebug operator<<(QDebug debug, QStyle::State state) } #endif +/*! + \since 4.6 + + \fn const QStyle * proxy() const + + This function returns the current proxy for this style. + By default most styles will return themselves. However + when a proxy style is in use, it will allow the style to + call back into its proxy. + + \sa setProxyStyle +*/ +const QStyle * QStyle::proxy() const +{ + Q_D(const QStyle); + return d->proxyStyle; +} + +/* \internal + + This function sets the base style that style calls will be + redirected to. Note that ownership is not transferred. +*/ +void QStyle::setProxy(QStyle *style) +{ + Q_D(QStyle); + d->proxyStyle = style; +} + QT_END_NAMESPACE |