• 5940阅读
  • 0回复

【提问】多线程程序问题 [复制链接]

上一主题 下一主题
离线wjydlut
 

只看楼主 倒序阅读 楼主  发表于: 2005-11-26
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
#include <qapplication.h>
#include <qthread.h>

class MyThread : public QThread
{
  Q_OBJECT
  public :
    virtual void run();
 
};

void MyThread::run()
{
  for(int x=0 ;x<20 ;x++)
  {
    sleep(10);
    qDebug("ping !");
  }
}

int main()
{
  MyThread a ;
  MyThread b ;
 
  a.start();
  b.start();
  a.wait();
  b.wait();
}

注: 已经在 .pro文件中加了CONFIG     += qt warn_on

出现下列错误:
.obj/yyyy.o(.text+0x53): In function `main':
/root/Desktop/wjy/paintmove/yyyy.cpp:23: undefined reference to `vtable for MyThread'
.obj/yyyy.o(.text+0x62):/root/Desktop/wjy/paintmove/yyyy.cpp:23: undefined reference to `vtable for MyThread'
.obj/yyyy.o(.text+0x99):/root/Desktop/wjy/paintmove/yyyy.cpp:23: undefined reference to `vtable for MyThread'
.obj/yyyy.o(.text+0xa8):/root/Desktop/wjy/paintmove/yyyy.cpp:23: undefined reference to `vtable for MyThread'
collect2: ld returned 1 exit status

请问那位知道为什么呀?谢谢!
[ 此贴被XChinux在2005-11-26 18:36重新编辑 ]
快速回复
限100 字节
 
上一个 下一个