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

Move Q_DECLARE_TR_FUNCTIONS into a smaller header

    XMLWordPrintable

    Details

    • Type: Suggestion
    • Status: Reported
    • Priority: Not Evaluated
    • Resolution: Unresolved
    • Affects Version/s: 5.15.1
    • Fix Version/s: None
    • Labels:
      None
    • Platform/s:
      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

            Assignee:
            thiago Thiago Macieira
            Reporter:
            EliteScience Heiko Thiel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes