Qt 获取当前线程ID并存储在变量中
您可以使用QThread::currentThreadId()将当前线程的ID存储在一个变量中。下面是一个示例代码:
#include <QThread>
#include <QDebug>
int main()
{
// 获取当前线程的ID
QThread::ThreadId threadId = QThread::currentThreadId();
// 将线程ID打印出来
qDebug() << 'Thread ID: ' << threadId;
return 0;
}
这样,您就可以将当前线程的ID存储在一个变量中,并在需要的时候使用。
原文地址: https://www.cveoy.top/t/topic/qwWV 著作权归作者所有。请勿转载和采集!