سؤال

  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.

هل كانت مفيدة؟

المحلول

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/

نصائح أخرى

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();
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top