[QtEI] Translation suggestion
Roland
qtextended.kossel at web.de
Thu Apr 30 23:29:11 CEST 2009
> > The disadvantage of using QObject::tr() compared to qApp->translate()
>
> eh? from what you wrote earlier i got the impression it is exactly the
> other way round.
You're right, kind of confusing. This is how I understood how it works:
When using QCoreApplication::translate() you have to provide the context
yourself.
When using QObject::tr(), the context is generated automatically by Qt. From
the documentation of Qt: "All QObject subclasses using the Q_OBJECT macro
automatically have a reimplementation of this function with the subclass
name as context." Therefore I have to correct my earlier explanation a
little bit: Inheriting from QObject is not sufficient, you must also supply
the Q_OBJECT macro.
When the macro is used in a class, Qt's moc (Meta-Object Compiler) generates
more information for the class - including the translation-context.
You can find more information about the meta-object system under
http://doc.trolltech.com/qtextended4.4/metaobjects.html.
I hope this didn't create more confusion...
Roland
More information about the community
mailing list