我尝试在QT中创建一个线程,可以声明、创建和启动它,但是它不会触发Run函数(我可以通过在该函数中放置断点来看到)。
VT.h:
class VT : public QThread
{
public:
void Run();
};VT.cpp
void VT::Run()
{
..
}在main.cpp中:
VT vt;
vt.Start();
// starts ok but no action我在VT.h中包含了其他标头,它们会阻塞吗?有一些不好的地方。有什么问题?
发布于 2009-08-15 12:04:11
Run函数以大写R开头,QThread的virtual run()是小写的。编译器认为您的Run()是与QThread完全无关的东西。
尝试将函数重命名为void VT::run()。
而且,像在QThread中一样,保护你的运行函数也是个好主意。
https://stackoverflow.com/questions/1281733
复制相似问题