diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-03-08 10:10:08 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-03-09 10:39:26 +0000 |
commit | ccb5f4481fd4b62f90b9ad8b93a0b5dd365cef5b (patch) | |
tree | 5c9b434205253383606e1a8d385c6a82fd9f7b44 /src/templates/qquickpopup.cpp | |
parent | 81e60ab430321d61196a9e044d8aeb89105a4565 (diff) |
Add QQuickPopup::setPosition() - C++ only API
This allows QQuickToolTip to initialize the position in one go.
Change-Id: I240a104f9a0f71549ab05be5fe097ca59bfed806
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'src/templates/qquickpopup.cpp')
-rw-r--r-- | src/templates/qquickpopup.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/templates/qquickpopup.cpp b/src/templates/qquickpopup.cpp index 6fa13475..a9374d05 100644 --- a/src/templates/qquickpopup.cpp +++ b/src/templates/qquickpopup.cpp @@ -702,6 +702,30 @@ void QQuickPopup::setY(qreal y) emit yChanged(); } +QPointF QQuickPopup::position() const +{ + Q_D(const QQuickPopup); + return QPointF(d->x, d->y); +} + +void QQuickPopup::setPosition(const QPointF &pos) +{ + Q_D(QQuickPopup); + const bool xChange = !qFuzzyCompare(d->x, pos.x()); + const bool yChange = !qFuzzyCompare(d->y, pos.y()); + if (!xChange && !yChange) + return; + + d->x = pos.x(); + d->y = pos.y(); + if (d->popupItem->isVisible()) + d->reposition(); + if (xChange) + emit xChanged(); + if (yChange) + emit yChanged(); +} + /*! \qmlproperty real Qt.labs.controls::Popup::z |