gpt4 book ai didi

qt - 无效的信号参数类型: MouseEvent

转载 作者:行者123 更新时间:2023-12-03 15:03:40 31 4
gpt4 key购买 nike

如果尝试在QML定义的信号中将MouseEvent用作arg,则在加载时会出现以下错误:

Invalid signal parameter type: MouseEvent



Qt文档中与此有关的信息存在冲突,在 QML signal syntax documentation中指出:

The allowed parameter types are the same as those listed under Defining Property Attributes [...] any QML object type can be used as a property type.



QML/C++ interaction documentation中指出:

When a QML object type is used as a signal parameter, the parameter should use var as the type



将参数设置为使用 var确实可以,但是根据QML文档,这似乎是不必要的。有关此 in the distant past的错误,但显然已在v5.0.0中解决。所以我做错了,还是这是回归?

编辑

一个简单的演示:
import QtQuick 2.3

Item {
signal sig( MouseEvent mouse )
}

最佳答案

改用QtObject

signal sig(QtObject mouse)

注意:之所以有效,是因为 QtObject是纯 QObject,它是所有Qt对象的基础

关于qt - 无效的信号参数类型: MouseEvent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25933918/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com