gpt4 book ai didi

c++ - QObject::connect() 带有枚举参数

转载 作者:行者123 更新时间:2023-11-30 04:29:43 25 4
gpt4 key购买 nike

我正在尝试将 QObject::connect() 与枚举参数一起使用。我收到这条消息...

QObject::connect: Incompatible sender/receiver arguments
Calendar::calendarExceptionThrown(Calendar*,ExceptionType)
--> CalendarDBView::handleCalendarException(Calendar*,Calendar::ExceptionType)

连接代码是:

 connect(cal, SIGNAL(calendarExceptionThrown(Calendar*,ExceptionType)),
this, SLOT(handleCalendarException(Calendar*,Calendar::ExceptionType)));

根据我的阅读,我认为我需要将其添加到 Calendar 的类定义中:

Q_ENUMS(ExceptionType)

我将此添加到 main.cpp:

qRegisterMetaType<Calendar::ExceptionType>("ExceptionType");

我仍然收到警告消息。 This related thread没有解决我的问题。我做错了什么?

最佳答案

我相信如果您只是在连接的 SIGNAL 部分将 ExceptionType 更改为 Calendar::ExceptionType,它就会解决问题。 moc 期望 SIGNAL 和 SLOT 的字符串匹配。

关于c++ - QObject::connect() 带有枚举参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9179584/

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