aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Junnonen <tomas.junnonen@nokia.com>2010-05-10 16:44:58 +0300
committerTomas Junnonen <tomas.junnonen@nokia.com>2010-05-11 19:44:43 +0300
commit1ca3769d4eae045ff3c4c0606b1345c1f1afee7f (patch)
tree15fe3af737c5167f1a41d5c3d5dc9a36ed8a02c2
parent5a383ee60f850704a78b3ff7624417bf44ba8c5a (diff)
Changes: Added paintOffset property to MWidget
RevBy: John Tapsell Details: This property allows to offset the widget display position without effecting for example the layout.
-rw-r--r--src/corelib/widgets/core/mwidget.cpp9
-rw-r--r--src/corelib/widgets/core/mwidget.h26
2 files changed, 35 insertions, 0 deletions
diff --git a/src/corelib/widgets/core/mwidget.cpp b/src/corelib/widgets/core/mwidget.cpp
index b050c386..a8bf75c2 100644
--- a/src/corelib/widgets/core/mwidget.cpp
+++ b/src/corelib/widgets/core/mwidget.cpp
@@ -455,3 +455,12 @@ void MWidget::setVisible(bool visible)
QGraphicsWidget::setVisible(visible);
}
+QPointF MWidget::paintOffset() const
+{
+ return QPointF(transform().dx(), transform().dy());
+}
+
+void MWidget::setPaintOffset(const QPointF &newOffset)
+{
+ setTransform(QTransform::fromTranslate(newOffset.x(), newOffset.y()));
+}
diff --git a/src/corelib/widgets/core/mwidget.h b/src/corelib/widgets/core/mwidget.h
index 7123ac1f..5756e230 100644
--- a/src/corelib/widgets/core/mwidget.h
+++ b/src/corelib/widgets/core/mwidget.h
@@ -47,6 +47,7 @@ class M_EXPORT MWidget : public QGraphicsWidget
Q_PROPERTY(QSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy)
Q_PROPERTY(bool selected READ isSelected WRITE setSelected)
Q_PROPERTY(bool onDisplay READ isOnDisplay)
+ Q_PROPERTY(QPointF paintOffset READ paintOffset WRITE setPaintOffset)
public:
MWidget(QGraphicsItem *parent = 0);
@@ -89,6 +90,31 @@ public:
*/
bool isSelected() const;
+ /*!
+ Returns the offset by which the widget will be transformed when painted.
+
+ This convenience function is equivalent to querying the horizontal and
+ vertical translation factors of the widgets's transform().
+
+ \sa setPaintOffset()
+ */
+ QPointF paintOffset() const;
+
+ /*!
+ Sets the offset by which the widget will be transformed when painted.
+
+ This convenience function is equivalent to calling setTransform on the widget,
+ supplying a QTransform that shifts the widget by \a offset.
+
+ The paint offset allows for a widget to appear as if in a position
+ different than that of the widget's pos() property. This allows for example
+ to animate the widget's apparent location using a QPropertyAnimation
+ without affecting layouting or the layout affecting the animation.
+
+ \sa paintOffset()
+ */
+ void setPaintOffset(const QPointF & offset);
+
/*! \reimp
* We reimplement these to distinguish between the user hiding items
* explicitly, and the layout hiding them.