Object::connect:没有这样的信号 MyThread::MySignal()
- 我的程序有一个线程类。
- 信号和槽都位于该线程类本身中。
- 头文件和源文件是分开的。
- main()函数位于源文件本身中。
在 main () 中,我使用 connect 如下:
MyThread objA;
Object :: connect (&objA, SIGNAL(MySignal()), &objA, SLOT(MySlot()));
.pro 文件是:
######################################################################
# Automatically generated by qmake (2.01a) Thu Dec 1 13:05:43 2011
######################################################################
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += qtWheel.h
SOURCES += qtWheel.cpp
我在运行时看到上述错误。请指导。
- My program has one thread class.
- The signal and the slot both are in that thread class itself.
- The header file and the source file are separate.
- main () function is in the source file itself.
In main (), I am using connect as follows:
MyThread objA;
Object :: connect (&objA, SIGNAL(MySignal()), &objA, SLOT(MySlot()));
.pro file is:
######################################################################
# Automatically generated by qmake (2.01a) Thu Dec 1 13:05:43 2011
######################################################################
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += qtWheel.h
SOURCES += qtWheel.cpp
I saw the above error during run time. Please guide.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了解决方案:
signal和slot函数的参数不匹配!我一修好它们,插槽就被调用了。
感谢: http://samdutton.wordpress .com/2008/10/03/debugging-signals-and-slots-in-qt/
I have found the solution:
The parameters of signal and slot functions were mismatching! As soon as I fixed them, the slot got called.
Thanks to: http://samdutton.wordpress.com/2008/10/03/debugging-signals-and-slots-in-qt/
您需要将 MySignal() 和 MySlot() 定义为 signal & MyThread 类的头文件中的槽:
You need to define the MySignal() and MySlot() as signal & slot in the header file of your MyThread class: