here’s the code of my problem
class Base : QThread
{
Q_OBJECT
virtual void run() = 0;
signals:
void Ping(int);
};
class Derived : public Base
{
void run()
{
emit Ping(42);
}
}
the signal(42) won’t reach/call to slots. what’s wrong?
thanks in advance.
Did that 100 times, it does work. Are you sure your base class is properly MOC’ed ? (i.e. defined in a file contained in HEADERS section of
.pro) Also when connecting your signal, check the return status ofQObject::connect(it’s a boolean). A good practice is something like thatAs Liz noticed, if something went wrong in your
connect, you can check the traces to know what happened.I can also note :
runin your base class, it’s already defined by QThreadQThread: Base class and Derived class belong to the thread which created them, not in the newly created thread;EDIT:
Edited to take into account liz’ interesting comment.