PDA

View Full Version : QTranslator::translate override



Kwakkie
31st May 2016, 12:59
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:


class CTranslationManager : public QTranslator
{
public:
// Constructors and Destructors
CTranslationManager();
virtual ~CTranslationManager();

//virtual QString translate(const char* context, const char* sourceText, const char* disambiguation = 0) const override; // Qt4 code
virtual QString translate(const char* context, const char* sourceText, const char* disambiguation = 0, int n = -1) const override
{
m_CurrentUntranslated = sourceText;
return QTranslator::translate(context, sourceText, disambiguation, n);
}

private:
mutable QString m_CurrentUntranslated;
};

anda_skoa
31st May 2016, 13:52
Maybe there is another translator installed that gets called before yours?

Cheers,
_

Kwakkie
31st May 2016, 15:34
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.