• 4347阅读
  • 0回复

qt线程问题 [复制链接]

上一主题 下一主题
离线zhyu0001
 
只看楼主 正序阅读 楼主  发表于: 2007-02-12
我是按照文档的来做的, 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
快速回复
限100 字节
 
上一个 下一个