1
기본적으로 일련의 버튼이있는 툴바 인 QML 앱에서 작업하고 있습니다. 내 마우스를 버튼 위에 올려 놓으면 툴팁을 표시하고 싶습니다. 그러나 이제는 툴팁을 호출 한 버튼을 제외한 모든 버튼 아래에 툴팁이 그려져 있습니다. 여기에 문제를QML. 다른 요소 위에 툴팁을 배치 할 때의 문제
Button.qml을 보여주는 빈약 한 예이다
import QtQuick 1.1
Rectangle
{
property color buttonColor: "red"
property color onHoverColor: "green"
property color borderColor: "blue"
property bool needTooltip: buttonMouseArea.containsMouse
id: button
width: 65
height: 82
radius: 1
color: buttonColor
signal buttonPressed()
MouseArea{
id: buttonMouseArea
anchors.fill: parent
onClicked: buttonPressed()
onPressed: button.color = borderColor
onReleased: button.color = onHoverColor
hoverEnabled: true
onEntered: button.color = onHoverColor
onExited: button.color = buttonColor
}
Rectangle {
id: tooltip
width: 75; height: 20
z: parent.z +10
visible: false
color: "peachpuff"
Text {
anchors.centerIn: parent
text: "My Tooltip"
}
states: State {
name: "inuse"
when: needTooltip
PropertyChanges {
target: tooltip
visible: true
x: buttonMouseArea.mouseX + 5
y: buttonMouseArea.mouseY - 25
}
}
}
}
나는 툴팁에서 다른 모든 것들 위에 표시 할 수있는 방법 main.qml
import QtQuick 1.1
Rectangle {
width: 1500
height: 200
Row
{
height: 80
anchors.centerIn: parent
spacing: 30
Button{
id: settingsButton;
}
Button{
id: listButton;
}
Button{
id: someOtherButton
}
}
}
내 프로그램? 버튼의 툴팁의 z 축 덤비는 것은 당신은 Button.qml
구성 요소의 외부 툴팁을 잡아 당기거나에 상주하는 QDeclarativeScene
에이 속한 QDeclarativeScene
에서 툴팁 QDeclarativeItem
를 분리하는 해킹을 작성해야
이 솔루션은 꽤 멋지게 보이지만 시도해 보겠습니다. 여분의 QWidgets을 사용하지 않고 툴팁을 별도의 .qml로 옮길 수 있습니까? (한눈에 어떻게 할 수 있는지 알 수 없으므로) – WereWind
분리 된'qml' = separate component. 중요한 것은 'Buttons'와 같은 구성 요소에서 인스턴스화 된 'Tooltip'항목입니다. 'Button's에 id를 제공해야합니다. 그래서 그들은 무엇을 볼 수 있는지 알 것입니다. 이동은 가능하지만 불필요합니다. – user1095108
그것은 작동합니다! 고맙습니다! – WereWind