Unsolved convert c++ class to qt class
-
Hi All,
hope someone can help with this. There's a c++ class in my qt code that I need to turn into a qt class ( sorry don't know correct term ). As I need to pass a signal from it. I've tried but get some errors to do with "vtables".
What I did was add #include <QObject> to my class header, changed the way the class is declared and the way the constructor is declared so in header I've replaced
[code]
class Bonus_Class
{
public:
Bonus_Class();
[/code]
with
[code]
class Bonus_Class : public QObject
{
Q_OBJECT
public:explicit Bonus_Class(QObject *parent = 0);
[/code]
then I've replace the constructor in my code with
[code]
//Bonus_Class::Bonus_Class()
//{
//}Bonus_Class::Bonus_Class(QObject *parent) :QObject(parent)
{}
[/code]
However this gives a vtable error, not sure what this is.
[code]
/bonus_class.cpp:11: error: undefined reference tovtable for Bonus_Class' /bonus_class.h:95: error: undefined reference to
vtable for Bonus_Class'
[/code]can anyone advise, I'm sure this is simple but I'm not used to QT. Thanks
-
Try to run qMake , than rebuild.
-
No need to change the constructor if your class does not need a parent.
Run qmake and rebuild your project. -
Thankyou all qmake worked