QT : QTranslate is not working with QObject subclass

123 Views Asked by At

QTranslate is working fine with tr and QObject::tr but when I try to create a subclass of QObject its generating the correct ts file but unable to read it back.

class Reporting : public QObject { };

Reporting::tr("I Am Reporting.");

please help Thanks in advance

1

There are 1 best solutions below

0
On BEST ANSWER

That's not a correct QObject. A designating macro and vtable are required, also you might want to provide ownership mechanism.

class Reporting : public QObject { 
       Q_OBJECT

       Reporting (/*whatever*/ QObject* parent = 0 )
       : QObject (parent) /*whatever*/ 
       { /*whatever*/ }

       ~Reporting ()
};

in C++ file

//virtual destructor
Reporting ::~Reporting () {}