summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qstyleoption.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2012-10-15 14:10:58 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-16 15:29:15 +0200
commit05c2113350a8abbb1df844a2b1d1befb95a93f5e (patch)
tree9afe7384246964b7b0ca64214feafbe2fcf54a5c /src/widgets/styles/qstyleoption.cpp
parent5fb7d6240b659d2ea176c1791c5f6e251a165061 (diff)
Add QObject* QStyleOption::styleObject
The object is used, amongst other things, as a target for sending style animation updates. Change-Id: Ic210e7ae2111bc08b70331a3a2030a494919a06d Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/widgets/styles/qstyleoption.cpp')
-rw-r--r--src/widgets/styles/qstyleoption.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index 3017f30470..8a469b496d 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -155,7 +155,7 @@ QT_BEGIN_NAMESPACE
QStyleOption::QStyleOption(int version, int type)
: version(version), type(type), state(QStyle::State_None),
- direction(QApplication::layoutDirection()), fontMetrics(QFont())
+ direction(QApplication::layoutDirection()), fontMetrics(QFont()), styleObject(0)
{
}
@@ -171,8 +171,8 @@ QStyleOption::~QStyleOption()
\fn void QStyleOption::initFrom(const QWidget *widget)
\since 4.1
- Initializes the \l state, \l direction, \l rect, \l palette, and
- \l fontMetrics member variables based on the specified \a widget.
+ Initializes the \l state, \l direction, \l rect, \l palette, \l fontMetrics
+ and \l styleObject member variables based on the specified \a widget.
This is a convenience function; the member variables can also be
initialized manually.
@@ -227,6 +227,7 @@ void QStyleOption::init(const QWidget *widget)
rect = widget->rect();
palette = widget->palette();
fontMetrics = widget->fontMetrics();
+ styleObject = const_cast<QWidget*>(widget);
}
/*!
@@ -235,7 +236,7 @@ void QStyleOption::init(const QWidget *widget)
QStyleOption::QStyleOption(const QStyleOption &other)
: version(Version), type(Type), state(other.state),
direction(other.direction), rect(other.rect), fontMetrics(other.fontMetrics),
- palette(other.palette)
+ palette(other.palette), styleObject(other.styleObject)
{
}
@@ -249,6 +250,7 @@ QStyleOption &QStyleOption::operator=(const QStyleOption &other)
rect = other.rect;
fontMetrics = other.fontMetrics;
palette = other.palette;
+ styleObject = other.styleObject;
return *this;
}
@@ -312,6 +314,15 @@ QStyleOption &QStyleOption::operator=(const QStyleOption &other)
*/
/*!
+ \variable QStyleOption::styleObject
+ \brief the object being styled
+
+ The built-in styles support the following types: QWidget, QGraphicsObject and QQuickItem.
+
+ \sa initFrom()
+*/
+
+/*!
\variable QStyleOption::rect
\brief the area that should be used for various calculations and painting
@@ -4056,6 +4067,7 @@ QDebug operator<<(QDebug debug, const QStyleOption &option)
debug << ',' << (option.direction == Qt::RightToLeft ? "RightToLeft" : "LeftToRight");
debug << ',' << option.state;
debug << ',' << option.rect;
+ debug << ',' << option.styleObject;
debug << ')';
#else
Q_UNUSED(option);