我正在尝试使用下面列出的QML代码中的imageUrl
函数,但是我收到以下错误:Property 'imageUrl' of object ApplicationWindow_QMLTYPE_39_QML_108(0x1934a60) is not a function
。
这是我的QML代码(请注意评论):
ApplicationWindow {
id:window
visible: true
width: 640
height: 480
title: qsTr("Open Picture")
menuBar: MenuBar {
Menu {
title: qsTr("File")
MenuItem {
text: qsTr("&Open")
onTriggered: fileDialoge.open()
}
MenuItem {
text: qsTr("Exit")
onTriggered: Qt.quit();
}
}
}
//this is my function
function imageUrl(text)
{
console.log("Url: " + text);
}
// the user browse image from here
FileDialog {
id: fileDialoge
nameFilters: [ "Image files (*.png *.jpg)", "All files (*)" ]
selectedNameFilter: "Image files (*.png *.jpg)"
selectMultiple: true
}
Button {
text: "Open"
anchors.verticalCenter: parent.verticalCenter
onClicked: fileDialoge.open()
}
// and I want the function to be called here
Button {
x: 136
text: "Send"
anchors.verticalCenterOffset: 0
anchors.verticalCenter: parent.verticalCenter
onClicked: window.imageUrl(FileDialog.fileUrl)
}
}