英文:
QML invalid property name "signal" M16
问题
我跟随了一个关于QML开发的教程(如果感兴趣,可以点击这个链接:https://www.youtube.com/watch?v=aMEQji7Rwrg ),在创建第一个屏幕对话框时,他使用信号来连接onClicked
信号来打开对话框,关闭对话框时也是一样的。但在我的代码中,这种方法不起作用,我收到了消息:"无效的属性名称"signal"。我尝试了一段时间的谷歌搜索,但没有找到有用的信息。
以下是出现问题的QML文件中的代码。如果需要,我还可以添加更多代码,但这就是问题出现的地方。
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Window 2.15
Rectangle
{
id: heatSelectDialog
signal: destroyMe()
anchors.fill: parent
color: Qt.rgba(0, 0, 0, 0)
MouseArea
{
anchors.fill: parent
onClicked: heatSelectDialog.destroyMe();
}
Rectangle
{
id: innerRectangle
width: parent.width / 2
height: parent.height * 0.8
color: "black"
border.color: "red"
border.width: 3
}
}
错误发生在这一行:signal: destroyMe
感谢您的帮助。
Kind regards,
Rolf Hausen
英文:
i follow a tutorial about QML Development
(in case of interest this one: https://www.youtube.com/watch?v=aMEQji7Rwrg )
at creating a first inscreen dialog he is using signal to connect the onClicked Signal
to open the dialog and the same for destroying it.
But in my Code this does not work and i get the message: "invalid property name "signal"
i tried to google this a while but i did not find anything helpful.
Here is the code from the qml file where it appears.
If needed i can also add more code. but this is where the issue appears.
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Window 2.15
Rectangle
{
id: heatSelectDialog
signal: destroyMe()
anchors.fill: parent
color: Qt.rgba(0, 0, 0, 0)
MouseArea
{
anchors.fill: parent
onClicked: heatSelectDialog.destroyMe();
}
Rectangle
{
id: innerRectangle
width: parent.width /2
height: parent.height * 0.8
color: "black"
border.color: "red"
border.width: 3
}
}
The error happens on the line: signal: destroyMe
i will be thanksful for your help
kind regards
Rolf Hausen
答案1
得分: 0
你在声明信号时有个拼写错误。那里不应该有冒号。所以不应该是这样的:
signal: destroyMe()
你应该使用这样的方式:
signal destroyMe()
英文:
You have a typo in the way that you declared your signal. There should not be a colon there. So rather than this:
signal: destroyMe()
You should be using this:
signal destroyMe()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论