0
我用下面的代碼設置一個按鈕按QML按鈕,但沒有任何反應
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!")
}
}
}
按下按鈕「世界你好」,應該點擊控制檯顯示器。
但它看起來像什麼也沒發生,當我點擊按鈕的所有QML
Button
您的評論歡迎
QML按鈕有它自己的信號點擊,你不需要MouseArea,使用點擊信號 – Chernobyl 2014-11-03 05:28:40
你是對的,謝謝 – arachide 2014-11-03 05:31:09
好吧,在這種情況下,我發佈這個答案 – Chernobyl 2014-11-03 05:34:16