I am writing an API that will be used when creating interfaces at work. The API allows the user to choose from a set of pre-built widgets and layouts so that within a short period of time it is possible to create several interfaces for different devices. There will be two translation files; one for the widget API (which comes with the library) and one more that the developer will create for user data in the interface. To simplify the work with the developer, I wanted the API to process the entire translation, passing the data name to the API, but I came to a stumbling block; I can't get the translator to recognize the translated text sent to him, but he recognizes local literals.
Here is a brief example of what I'm talking about.
class Object { public: Object(QString name) { m_Name = name; }; QString name() { return m_Name; }; private: QString m_Name; }; class MyWidget : public QPushButton, public Object { Q_OBJECT public: MyWidget(QString name); ~MyWidget(); void retranslate(); protected slots: void buttonPressed(); void changeEvent(QEvent* event); private: enum Language { ENGLISH, JAPANESE }; Language m_Language; QTranslator* m_pTranslator; }; MyWidget::MyWidget(QString name) :Object(name)
I typed this manually, so there might be a few typos, but the concept still remains true - you have to call setText in the same class as your character. If you pass a literal to a class like I am here, it will be ignored. If I make a literal in the class, it works fine. This is a problem because I want the developer to pass the literal to the class and then give it a translation. The developer will still have to make their own translations, but I donβt want them to worry about working with translations.
Am I doing something wrong or is this a limitation of Qt?
Richard
source share