Gourav Rana
Gourav Rana

Reputation: 64

QT : QTranslate is not working with QObject subclass

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

Upvotes: 0

Views: 134

Answers (1)

Swift - Friday Pie
Swift - Friday Pie

Reputation: 14589

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 () {}

Upvotes: 1

Related Questions