0
请有人解释我一件事。假设我有一个项目,如果我点击它,那么会出现一个下拉菜单。当你将鼠标悬停在菜单项上时,如何做到这一点?QML MenuItem突出显示不起作用
代码:
Rectangle {
id: main_window
width: 600
height: 600
property int mrg: 10
Rectangle {
anchors.centerIn: parent
width: 500
height: 500
color: 'green'
Text {
id: field
text: "Click!"
font.pointSize: 20
color: 'white'
anchors.centerIn: parent
MouseArea {
id: ma
anchors.fill: parent
hoverEnabled: true
onClicked: {
menu.x = ma.mouseX
menu.open()
}
}
Menu {
id: menu
y: field.height
MenuItem {
text: "Menu item"
highlighted: true
}
}
}
}
}
在本文档中,我碰到了合适的highlight
负责选择相应的菜单项的地步。我将它安装在True中,但它没有改变任何东西。 请告诉我我做错了什么。非常感谢。
非常感谢您的帮助。是工作! –