小编Thu*_*orm的帖子

如何设置QWebChannel JS API以在QWebEngineView中使用?

由于Qt的文档远未完成,这是设置QWebChannel的方法,并且<script>在HTML页面中添加标签与文档中推荐的标签有什么不同?

javascript c++ qt

4
推荐指数
1
解决办法
3125
查看次数

创建线程时编译器错误

每次调用ObjParser :: loadData()时我都会尝试启动一个新线程,就像他们在这个例子中所做的那样.

所以我写了这段代码.

#include <thread>   
void ObjParser::loadData()
{
   thread loadingThread(_loadData);
   loadingThread.detach();
}

void ObjParser::_loadData()
{
   //some code
}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试编译它时,我收到此错误:

error C3867: 'ObjParser::_loadData': function call missing argument list; use '&ObjParser::_loadData' to create a pointer to member
Run Code Online (Sandbox Code Playgroud)

所以我创建了一个指向成员函数的指针:

#include <thread>   
void ObjParser::loadData()
{
   thread loadingThread(&ObjParser::_loadData);
   loadingThread.detach();
}

void ObjParser::_loadData()
{
   //some code
}
Run Code Online (Sandbox Code Playgroud)

但是编译器抱怨说:

error C2064: term does not evaluate to a function taking 0 arguments 
Run Code Online (Sandbox Code Playgroud)

我不知道导致问题的原因,请你给我一个如何解决这个问题的提示.

c++ multithreading stl c++11

0
推荐指数
1
解决办法
335
查看次数

标签 统计

c++ ×2

c++11 ×1

javascript ×1

multithreading ×1

qt ×1

stl ×1