Results 1 to 3 of 3

Thread: QTranslator::translate override

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2012
    Posts
    37
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default QTranslator::translate override

    We are in the process of upgrading from Qt 4.8.7 to Qt 5.5.1. In our software, I have a class derived from QTranslator. The class overrides the translate function. We do this to keep the last untranslated string in memory. This works fine in Qt4.8.7. The overridden translate function is called during program execution. Going to Qt5, a parameter is added, but otherwise the function looks the same. We we adjusted the override for this parameter. Yet when running the software the overridden translate function is never called. I'm at a loss why this is happening. Any ideas?

    Basically, something like this:
    Qt Code:
    1. class CTranslationManager : public QTranslator
    2. {
    3. public:
    4. // Constructors and Destructors
    5. CTranslationManager();
    6. virtual ~CTranslationManager();
    7.  
    8. //virtual QString translate(const char* context, const char* sourceText, const char* disambiguation = 0) const override; // Qt4 code
    9. virtual QString translate(const char* context, const char* sourceText, const char* disambiguation = 0, int n = -1) const override
    10. {
    11. m_CurrentUntranslated = sourceText;
    12. return QTranslator::translate(context, sourceText, disambiguation, n);
    13. }
    14.  
    15. private:
    16. mutable QString m_CurrentUntranslated;
    17. };
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTranslator::translate override

    Maybe there is another translator installed that gets called before yours?

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    Kwakkie (31st May 2016)

  4. #3
    Join Date
    May 2012
    Posts
    37
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTranslator::translate override

    Looks more like mine is replaced after intalled. As a test, I remove and install the same translator. At that point it works. Now to dig deeper and find out where the other translator is installed. Thanks.

Similar Threads

  1. QTranslator checking
    By arturs in forum Newbie
    Replies: 1
    Last Post: 29th April 2015, 23:18
  2. QTranslator in Android
    By marnando in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 25th February 2014, 16:33
  3. QTranslator??
    By nthung in forum Newbie
    Replies: 21
    Last Post: 15th October 2011, 03:33
  4. Help with QTranslator
    By aarelovich in forum Qt Programming
    Replies: 1
    Last Post: 24th July 2009, 22:38
  5. Want to use QTranslator
    By santhoshv84 in forum Qt Programming
    Replies: 1
    Last Post: 27th August 2008, 15:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.