作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 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/
我是一名优秀的程序员,十分优秀!