QT获取当前线程ID

QT获取当前线程ID

用QSerialPort串口类的时候出现了:
[WARNING ] QObject: Cannot create children for a parent that is in a different thread.
(Parent is QSerialPort(0x505f250), parent’s thread is QThread(0x2b7ff0), current thread is QThread(0x563a860)

于是想要输出一下到底现在是在哪个线程里跑,不废话,直接上代码:

 QString LogInfo;
    LogInfo.sprintf("%p", QThread::currentThread());
    qDebug() << "OpenSerialPort " <<"threadID : "<

你可能感兴趣的:(QT编程)