Object::connect:没有这样的信号 MyThread::MySignal()

发布于 2024-12-19 10:45:56 字数 760 浏览 3 评论 0原文

  1. 我的程序有一个线程类。
  2. 信号都位于该线程类本身中。
  3. 头文件和源文件是分开的。
  4. ma​​in()函数位于源文件本身中。

ma​​in () 中,我使用 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

我在运行时看到上述错误。请指导。

  1. My program has one thread class.
  2. The signal and the slot both are in that thread class itself.
  3. The header file and the source file are separate.
  4. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

满身野味 2024-12-26 10:45:56

我找到了解决方案:
signalslot函数的参数不匹配!我一修好它们,插槽就被调用了。

感谢: 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/

毅然前行 2024-12-26 10:45:56

您需要将 MySignal() 和 MySlot() 定义为 signal & MyThread 类的头文件中的槽:

class MyThread
{
public:
    MyThread();
signals:
    void MySignal();
public slots:
    void MySlot();
}

You need to define the MySignal() and MySlot() as signal & slot in the header file of your MyThread class:

class MyThread
{
public:
    MyThread();
signals:
    void MySignal();
public slots:
    void MySlot();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文