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>
This commit is contained in:
J-P Nurmi 2012-10-15 14:10:58 +02:00 committed by The Qt Project
parent 5fb7d6240b
commit 05c2113350
2 changed files with 17 additions and 4 deletions

View File

@ -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;
}
@ -311,6 +313,15 @@ QStyleOption &QStyleOption::operator=(const QStyleOption &other)
\sa initFrom()
*/
/*!
\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);

View File

@ -89,6 +89,7 @@ public:
QRect rect;
QFontMetrics fontMetrics;
QPalette palette;
QObject *styleObject;
QStyleOption(int version = QStyleOption::Version, int type = SO_Default);
QStyleOption(const QStyleOption &other);