aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitem.h
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-09-28 11:00:40 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-10-13 17:24:41 +0000
commit1e3df38bcb61054d53b0853fa2648aae87f1044b (patch)
treea7579d53b693b5c1449bbed5817328f8fb6fe00e /src/quick/items/qquickitem.h
parentb4cdfc4a12d2b9ebc79fe17a2f1aff67bd940d71 (diff)
Item: sort out mapFromGlobal() and mapToGlobal()
The commit message of 08327da, and the change log of Qt 5.7.0 promised that mapFromGlobal() and mapToGlobal() were available in QML. But since the revision 7 of QQuickItem was not registered, this was not entirely true. Due to a little quirk in the QML engine's handling of revisioned methods, mapFromGlobal() and mapToGlobal() were only accessible via an identifier or property, but not directly: // works MouseArea { id: ma; onClicked: console.log(ma.mapToGlobal(Qt.point(mouse.x, mouse.y))) } // ReferenceError: mapToGlobal is not defined MouseArea { onClicked: console.log(mapToGlobal(Qt.point(mouse.x, mouse.y))) } Furhermore, this is inconsistent with how mapFromItem() and mapToItem() are exposed to QML. Even though the C++ versions of these methods take QPointF and QRectF, the QML versions take 2-4 number specifying x, y, width and height: object mapFromItem(Item item, real x, real y) object mapFromItem(Item item, real x, real y, real width, real height) object mapToItem(Item item, real x, real y) object mapToItem(Item item, real x, real y, real width, real height) Therefore the signature of mapFromGlobal() and mapToGlobal() should be: object mapFromGlobal(real x, real y) object mapToGlobal(real x, real y) This change implements the QML versions of these methods using QQmlV4Function, and adds the missing documentation for the QML API. NOTE: This is QML-only API. Change-Id: I2ced4836d274c7d1e644ea29fc25dbdd2045001b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/quick/items/qquickitem.h')
-rw-r--r--src/quick/items/qquickitem.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h
index c4ee48fdbd..5f5a141922 100644
--- a/src/quick/items/qquickitem.h
+++ b/src/quick/items/qquickitem.h
@@ -321,12 +321,12 @@ public:
QTransform itemTransform(QQuickItem *, bool *) const;
QPointF mapToItem(const QQuickItem *item, const QPointF &point) const;
QPointF mapToScene(const QPointF &point) const;
- Q_REVISION(7) Q_INVOKABLE QPointF mapToGlobal(const QPointF &point) const;
+ QPointF mapToGlobal(const QPointF &point) const;
QRectF mapRectToItem(const QQuickItem *item, const QRectF &rect) const;
QRectF mapRectToScene(const QRectF &rect) const;
QPointF mapFromItem(const QQuickItem *item, const QPointF &point) const;
QPointF mapFromScene(const QPointF &point) const;
- Q_REVISION(7) Q_INVOKABLE QPointF mapFromGlobal(const QPointF &point) const;
+ QPointF mapFromGlobal(const QPointF &point) const;
QRectF mapRectFromItem(const QQuickItem *item, const QRectF &rect) const;
QRectF mapRectFromScene(const QRectF &rect) const;
@@ -334,6 +334,8 @@ public:
Q_INVOKABLE void mapFromItem(QQmlV4Function*) const;
Q_INVOKABLE void mapToItem(QQmlV4Function*) const;
+ Q_REVISION(7) Q_INVOKABLE void mapFromGlobal(QQmlV4Function*) const;
+ Q_REVISION(7) Q_INVOKABLE void mapToGlobal(QQmlV4Function*) const;
Q_INVOKABLE void forceActiveFocus();
Q_INVOKABLE void forceActiveFocus(Qt::FocusReason reason);
Q_REVISION(1) Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward = true);