'QML: Hide ToolTip when outside of ScrollView
In the example code, ToolTip text gets above header and footer. Is there a way to hide ToolTip when it is outside of ScrollView?
The idea is to have TextInputs and show tooltip when it have focus. Here I have replaced TextInput with Buttons for simplification.
import QtQuick 2.14
import QtQuick.Window 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
ColumnLayout {
anchors.fill: parent
Layout.fillWidth: true
spacing: 0
Rectangle {
id: headerRect
Layout.fillWidth: true
height: 150
color: "blue"
z: 1
}
ScrollView {
id: scrollview
Layout.fillWidth: true
Layout.fillHeight: true
ListView{
id: listview
model: {1;2;3;4;5;6;7;8;9}
spacing: 1
delegate: Button {
text: "Button"
ToolTip{
visible: parent.focus? true : false
text: "tooltip text"
}
}
}
}
Rectangle {
id: footerRect
Layout.fillWidth: true
height: 150
color: "blue"
z: 1
}
}
}
Solution 1:[1]
use hovered replace focurse
ToolTip{
visible: parent.hovered ? true : false
text: "tooltip text"
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sonicss |
