In the following code i got compilation erros like below
/thread.cpp:20: undefined reference to `vtable for MyThread'
thread.cpp:6: undefined reference to `vtable for MyThread'
MyThread.h file is
#ifndef MYTHREAD_H
#define MYTHREAD_H
#include <QThread>
#include <QObject>
{
Q_OBJECT
public:
~MyThread();
public slots:
void Finished();
protected:
void run();
};
#endif //MYTHREAD_H
#ifndef MYTHREAD_H
#define MYTHREAD_H
#include <QThread>
#include <QObject>
class MyThread:public QThread
{
Q_OBJECT
public:
MyThread(QWidget* aParent);
~MyThread();
public slots:
void Finished();
protected:
void run();
};
#endif //MYTHREAD_H
To copy to clipboard, switch view to plain text mode
and MyThread.cpp is
#include "thread.h"
#include <iostream.h>
#include <QMetaType>
MyThread
::MyThread(QWidget* aParent
){
qRegisterMetaType<MyThread*>("MyThread");
QObject::connect(this,
SIGNAL(finished
()),
this,
SLOT(Finished
()));
if(!isRunning())
{
start();
}
else
{
return;
}
}
MyThread::~MyThread()
{
}
void MyThread::run()
{
cout <<"Hello :" << endl;
}
void MyThread::Finished()
{
cout << "In Finishes:" << endl;
}
#include "thread.h"
#include <iostream.h>
#include <QMetaType>
MyThread::MyThread(QWidget* aParent)
{
qRegisterMetaType<MyThread*>("MyThread");
QObject::connect(this,SIGNAL(finished()),this,SLOT(Finished()));
if(!isRunning())
{
start();
}
else
{
return;
}
}
MyThread::~MyThread()
{
}
void MyThread::run()
{
cout <<"Hello :" << endl;
}
void MyThread::Finished()
{
cout << "In Finishes:" << endl;
}
To copy to clipboard, switch view to plain text mode
and main.cpp is
int main(int argc,char* argv[])
{
QtopiaApplication app(argc,argv);
lWidget->setGeometry(0,0,240,320);
MyThread* lThread = new MyThread(lWidget);
Widget->show();
return app.exec();
}
int main(int argc,char* argv[])
{
QtopiaApplication app(argc,argv);
QWidget* lWidget = new QWidget;
lWidget->setGeometry(0,0,240,320);
MyThread* lThread = new MyThread(lWidget);
Widget->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Now whts the problem in above code and wts the reason for that.
Bookmarks