启动 start()
2、
QThread *p = new QThread
this->moveToThread(p)
connect(p, SIGNAL(started()), this, slot( xxfun() ))
p->start()
3、QtConcurrent::run( )
void printMes(bool *TF )
{
qDebug()<<"pprintMes(char*mes) thread : "<
qDebug()<<*TF
}
void sendQThread::printString( QString str )
{
qDebug()<<str << QThread::currentThreadId()
}
3.1创建
m_threadFlag= true
QtConcurrent::run(printMes, &m_threadFlag)
3.2创建
QString str = QString("我去%1").arg(i)
QtConcurrent::run(this, &sendQThread::printString, str )
QString hello(QString name)
{
qDebug() <<"Hello"<<name <<"from"<<QThread::currentThread()
return name
}
//掉用处QFuture f1 = QtConcurrent::run(hello, QString("Alice"))QFuture f2 = QtConcurrent::run(&threadPool, hello, QString("Bob"))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)