我是按照文档的来做的,
http://www.qtopia.org.cn/doc/qiliang.net/qt/qthread.html#include <qthread.h>
class MyThread : public QThread
{
public:
virtual void run();
};
void MyThread::run()
{
for( int count = 0; count < 20; count++ )
{
sleep( 1 );
qDebug( "Ping!" );
}
}
int main()
{
MyThread a;
MyThread b;
a.start();
b.start();
a.wait();
b.wait();
}
然后用g++ -g -I/usr/lib/qt-3.3/include -o thread thread.cpp -lqt-mt
编译后就出错thread.cpp:4: error: expected class-name before '{' token
thread.cpp: In function `int main()':
thread.cpp:24: error: 'class MyThread' has no member named 'start'
thread.cpp:25: error: 'class MyThread' has no member named 'start'
thread.cpp:26: error: 'class MyThread' has no member named 'wait'
thread.cpp:27: error: 'class MyThread' has no member named 'wait