【发布时间】:2014-11-03 05:01:10
【问题描述】:
我使用下面的代码设置了一个按钮
Button {
x: 141
y: 312
width: 98
height: 22
text: qsTr("Hello World")
anchors.verticalCenterOffset: 116
anchors.horizontalCenterOffset: -59
anchors.centerIn: parent
MouseArea
{
anchors.rightMargin: 126
anchors.bottomMargin: -172
anchors.leftMargin: -126
anchors.topMargin: 172
preventStealing: true
anchors.fill: parent
onPressed: {
console.debug("clicked!")
}
}
}
按下按钮“hello world”,它应该显示在控制台上单击。
但是当我点击按钮时似乎什么都没有发生
欢迎评论
【问题讨论】:
-
QML Button 有自己的点击信号,所以你不需要 MouseArea,使用点击信号
-
你是对的,谢谢
-
好的,在这种情况下,我将其发布为答案