Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-87165

Move Q_DECLARE_TR_FUNCTIONS into a smaller header

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 5.15.1
    • None
    • All

    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

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            EliteScience Heiko Thiel
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes