[Development] Execute a function in the specified existing thread

Thiago Macieira thiago.macieira at intel.com
Wed Jun 7 17:20:21 CEST 2023


On Wednesday, 7 June 2023 01:53:47 PDT JiDe Zhang wrote:
> I am writing a tool to allowed call a function in the specified existing
> thread, I want to contribution it to Qt project, are you like?

We do this internally, but don't usually expose it. If you're going to 
contribute it, please make sure your contribution uses QMetaCallEvent.

Anyway, the important question is whether you have the QThread for that thread 
or an object that lives in that thread. If you have the latter, it's already 
easy to do so:

  QMetaObject::invokeMethod(obj, Qt::QueuedConnection, [] { doSomething(); });

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5152 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20230607/dbe25d74/attachment.bin>


More information about the Development mailing list