【发布时间】:2015-05-07 17:33:00
【问题描述】:
我使用信号clicked 创建了我自己的项目,该项目包含 MouseArea。当单击 MouseArea 时,我想发出信号 clicked。但没有任何效果。
这是我的 .qml 代码:
import QtQuick 2.4
Item {
id: baseButton
property alias text: txt.text
width: txt.width
height: txt.height
signal clicked
onClicked : console.log("Clicked!")
Text {
id: txt
color: "white"
font.pointSize: 8
anchors.centerIn: parent
}
MouseArea {
id: mousearea
anchors.fill: parent
hoverEnabled: true
onEntered: {
txt.color = "yellow"
txt.font.pointSize = 15
}
onExited: {
txt.color = "white"
txt.font.pointSize = 8
}
onClicked: baseButton.clicked
}
}
非常感谢您的帮助!
【问题讨论】:
标签: qt qml signals-slots