Details
-
Type:
Suggestion
-
Status: Reported
-
Priority:
Not Evaluated
-
Resolution: Unresolved
-
Affects Version/s: 5.15.1
-
Fix Version/s: None
-
Component/s: Core: QString and Unicode
-
Labels:None
-
Platform/s:
Description
When you have a class which contains string to translate, you have currently 4 choice:
- Use QObject::tr =>bad to maintain tr files
- Use QCoreApplication::translate => passing the class name as string is bad for refactorings
- Inherit by QObject => a moc file will be generated, even it doesn't contain anything required and QObject doesn't have a copy constructor
- Use Q_DECLARE_TR_FUNCTIONS => sounds nice, but your header are getting bloated with unnecessary includes
How it could be solved:
- Simple class which use a forward declaration for QString and the implementation is within a cpp file (QObject then should inherit from this tiny class)
- Move Q_DECLARE_TR_FUNCTIONS to a separate header and move the call QCoreApplication::translate to a cpp file