qml 自定义信号
诸位老师好。我在qml 定义一个信号,调用的时候,却出现如下的错
file:///d:/qmlDemo/first.qml:31: ReferenceError: Can't find variable :buttonClick
first.qml 代码如下:
import QtQuick 1.0Rectangle { width: 400 height: 200 color: "lightblue" id:aa Text{ id:bb anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter wrapMode: Text.WordWrap font.pixelSize: 48 font.italic: true text:"Press me" signal buttonClick() onButtonClick: { if(mouse.button==Qt.RightButton){ parent.color="blue" }else { parent.color="red" } } MouseArea { anchors.fill: parent acceptedButtons: Qt.LeftButton|Qt.RightButton onClicked: buttonClick() } } TextInput { id:input x:50;y:150 width: 100 text:"<html><b>Qt Quick</b></html>" } Image { width: 50 height:50 source:"C:/Users/Public/Pictures/Sample Pictures/Chrysanthemum.jpg" }}