Question

I have the next classes: FoxCom and FoxComCircle. In FoxCom I have the next code:

...
public slots:
 void bytesWrite(QByteArray bytes, qint32 requestedTimeout = -1);
...
FoxComCircle * circle;
...

void FoxCom::bytesWrite(QByteArray bytes, qint32 requestedTimeout)
{
    QMetaObject::invokeMethod(circle,
                              //SLOT(bytesToWrite(QByteArray,qint32)),
                              "bytesToWrite",
                              Qt::QueuedConnection,
                              Q_ARG(QByteArray, bytes),
                              Q_ARG(qint32, requestedTimeout));
}

And in FoxComCircle:

...
public slots:
  void bytesToWrite(QByteArray bytes, qint32 requestedTimeout);
...
void FoxComCircle::bytesToWrite(QByteArray bytes, qint32 requestedTimeout)
{
   //some stinky code here
}

And there is the next behaviour: when I comment "bytesToWrite", and use SLOT(bytesToWrite(QByteArray,qint32)), I have the next message in the output console when FoxCom::bytesWrite is called:

QMetaObject::invokeMethod: No such method FoxComCircle::1bytesToWrite(QByteArray

,qint32)(QByteArray,qint32)

But when I use the const char * name directly (as shown in the code above) it works.

Am I doing something wrong?

P.S. FoxCom and FoxComCircle are in different threads.

Thanks in advance.

Was it helpful?

Solution

According to QMetaObject::invokeMethod description in Qt documentation:

Invokes the member (a signal or a slot name) on the object obj...

Thus, you have to provide the name of the slot, and not the complete signature. This is consistent, because you provide slot's arguments as the following arguments of invokeMethod function.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top