Hi everybody,
I would like to know usage of QT_TR_NOOP() (not QT_TRANSLATE_NOOP()).
I use the Qt SDK 4.5.1 in Linux/X11 and work in Qt Creator 1.1.0.
I wrote a sample code as follows.
#include <QApplication>
#include <QMainWindow>
#include <QTranslator>
#include <QString>
#include <QtGlobal>
class MyMessage {
Q_DECLARE_TR_FUNCTIONS(MyMessage)
public:
MyMessage(){}
~MyMessage(){}
static const char* message = QT_TR_NOOP("Hello");
}
};
int main(int argc, char *argv[])
{
translator.load("./MyAppMessages.qm");
application.installTranslator(&translator);
mainWindow.setWindowTitle(MyMessage::GetMessage());
mainWindow.show();
return application.exec();
}
#include <QApplication>
#include <QMainWindow>
#include <QTranslator>
#include <QString>
#include <QtGlobal>
class MyMessage {
Q_DECLARE_TR_FUNCTIONS(MyMessage)
public:
MyMessage(){}
~MyMessage(){}
static QString GetMessage() {
static const char* message = QT_TR_NOOP("Hello");
return QString(QObject::tr(message));
}
};
int main(int argc, char *argv[])
{
QApplication application(argc, argv);
QMainWindow mainWindow;
QTranslator translator;
translator.load("./MyAppMessages.qm");
application.installTranslator(&translator);
mainWindow.setWindowTitle(MyMessage::GetMessage());
mainWindow.show();
return application.exec();
}
To copy to clipboard, switch view to plain text mode
And I made "MyAppMessages.qm" with lupdate, Qt Linguist, and lrelease to translate the message "Hello" into Japanese.
And I built and ran the program.
but window title was "Hello" yet.
Although I am studying English hard, my English is not great yet,
and I may make many mistakes. So, please be patient with me.
Thank you very much for any kind of help.
kichi
Bookmarks