Proper usage of QMetaObject::invokeMethod



  • Hello,

    I read that QMetaObject::invokeMethod shall be used to invoke methods of an object which is affined to a different thread from the calling thread. Lets suppose we have two threads a pthread and a qthread. Is it allowed to call QMetaObject::invokeMethod from pthread to invoke a method of a worker object in Qthread. Could you please help me understand this.


  • Moderators

    @Usman93 said:

    I read that QMetaObject::invokeMethod shall be used to invoke methods of an object which is affined to a different thread from the calling thread.

    Correct.

    Lets suppose we have two threads a pthread and a qthread. Is it allowed to call QMetaObject::invokeMethod from pthread to invoke a method of a worker object in Qthread.

    Yes, it's allowed.

    Could you please help me understand this.

    See http://doc.qt.io/qt-5/qmetaobject.html#invokeMethod for some example code.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.