QML ToolTip placement
-
I'm adding tool tips to the QML:
Text { id:hdgValue text: heading ? setPrecision (rad2Deg (heading), 4) : "N/A" verticalAlignment: Text.AlignTop horizontalAlignment: Text.AlignLeft font.pointSize: parent.width < 150 ? 16 : 22 width: parent.width color: heading ? theme.accent : theme.caution ToolTip.visible: ma.containsMouse ToolTip.text: "Heading Tooltip" MouseArea { id: ma anchors.fill: parent hoverEnabled: true } }The tool tip appears approximately 200 pixels to the right of the data item, why? Can I specify that the tool tip should appear directly under the data item it relates too ?
-
I'm adding tool tips to the QML:
Text { id:hdgValue text: heading ? setPrecision (rad2Deg (heading), 4) : "N/A" verticalAlignment: Text.AlignTop horizontalAlignment: Text.AlignLeft font.pointSize: parent.width < 150 ? 16 : 22 width: parent.width color: heading ? theme.accent : theme.caution ToolTip.visible: ma.containsMouse ToolTip.text: "Heading Tooltip" MouseArea { id: ma anchors.fill: parent hoverEnabled: true } }The tool tip appears approximately 200 pixels to the right of the data item, why? Can I specify that the tool tip should appear directly under the data item it relates too ?
@SPlatten
I think you should be able to use the mechanisms described under popup positioning for tooltips also. -
@SPlatten
I think you should be able to use the mechanisms described under popup positioning for tooltips also.@Asperamanca , thank you, surely I can't be the only one experiencing this, isn't there a way to do this correctly with tooltips ?
-
As Asperamanca pointed out, ToolTip is a subclass of Popup. Maybe try to create an instance of tooltip and set x and y to it.
-
@JoeCFD , thank you, actually I don't see any mention in his post of it being a sub-class, however now I know that I will take another look.
@SPlatten https://doc.qt.io/qt-6/qml-qtquick-controls2-tooltip.html : "Inherits: Popup"