workerthread.cpp 376 B

1234567891011121314151617181920
  1. #include "workerthread.h"
  2. WorkerThread::WorkerThread(QObject *parent)
  3. : QObject(parent)
  4. {
  5. }
  6. WorkerThread::~WorkerThread()
  7. {
  8. }
  9. /* 这个函数是运行在多线程里面 */
  10. void WorkerThread::doWork(std::function<int (void *)> fun, void *parameter)
  11. {
  12. //从外面传递一个函数进来,执行
  13. int ret = fun(parameter);
  14. emit resultReady(ret);
  15. }