Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.11.0, 6.0.0
-
None
Description
The only requirement for https://doc.qt.io/qt-5/qml-qtquick-item.html#containmentMask-prop is that it is a QObject-derived type with an invokable contains(QPointF) function. This means that QtObject can also be used, not just Item. The documentation should be clearer about this by providing an example that uses QtObject. Even more important is the fact that type annotations are required on the function in order for QMetaObject to recognise it:
import QtQml import QtQuick Window { id: window visible: true width: 640 height: 480 Rectangle { id: control width: 10 height: 100 color: tapHandler.pressed ? Qt.darker("#444") : (hoverHandler.hovered ? Qt.lighter("#444") : "#444") anchors.centerIn: parent TapHandler { id: tapHandler } HoverHandler { id: hoverHandler } containmentMask: QtObject { id: mask function contains(point: point) : bool { let size = 30 let bounds = Qt.rect((control.width - size) / 2, 0, size, control.height) print("hello", point, bounds) return point.x >= bounds.x && point.x < bounds.x + bounds.width && point.y >= bounds.y && point.y < bounds.y + bounds.height } } } }
Attachments
Issue Links
- relates to
-
QTBUG-89375 No C++ documentation for containmentMask
- Closed
-
QTBUG-89380 Cannot use QtObject as containmentMask
- Closed
- resulted from
-
QTBUG-82678 Make SplitView use the touch area for hit testing
- Closed