QFutureWatcher获取QtConcurrent::run线程函数的返回值

 
  

QFutureWatcher获取QtConcurrent::run线程函数的返回值

mythread.h

#ifndef MYTHREAD_H
#define MYTHREAD_H
#include
#include
#include
#include
#include
#include
​
class myThread :public QThread,QRunnable
{
public:
    myThread();
​
    void run() override;
​
    int  test(int c, int b);
    void testFuture();
};
​
#endif // MYTHREAD_H
​

mythread.cpp

#include "mythread.h"
#include
#include
#include
​
myThread::myThread()
{
    qDebug()<<"myThread cons"<
#include
#include 
#include"mythread.h"
​
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();
​
    qDebug()<<"main thread id = "<testFuture();
​
​
​
    return a.exec();
}
​

你可能感兴趣的:(程序开发,开发语言,qt,c++)