[英]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. QTranslate 在 tr 和 QObject::tr 上工作正常,但是当我尝试创建 QObject 的子类时,它会生成正确的 ts 文件但无法读取它。
class Reporting : public QObject { };
Reporting::tr("I Am Reporting.");
please help Thanks in advance请帮助提前致谢
That's not a correct QObject.这不是一个正确的 QObject。 A designating macro and vtable are required, also you might want to provide ownership mechanism.需要指定宏和 vtable,您也可能希望提供所有权机制。
class Reporting : public QObject {
Q_OBJECT
Reporting (/*whatever*/ QObject* parent = 0 )
: QObject (parent) /*whatever*/
{ /*whatever*/ }
~Reporting ()
};
in C++ file在 C++ 文件中
//virtual destructor
Reporting ::~Reporting () {}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.