QTranslator doc: use QCoreApplication::installTranslator()
The example snippet was using app.installTranslator() even installTranslator() is a static function. And since app is a QApplication instead a QCoreApplication this could lead to the assumption that a QTranslator can only be used for gui applications. Therefore use the correct static invocation QCoreApplication::installTranslator(). Change-Id: Ia3ce00f25230c2fe2bdc159ec14c88c961924651 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
3d7207414b
commit
16da0b2cf8
@ -56,13 +56,13 @@ int main(int argc, char *argv[])
|
|||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
// look up e.g. :/translations/myapp_de.qm
|
// look up e.g. :/translations/myapp_de.qm
|
||||||
if (translator.load(QLocale(), QLatin1String("myapp"), QLatin1String("_"), QLatin1String(":/translations")))
|
if (translator.load(QLocale(), QLatin1String("myapp"), QLatin1String("_"), QLatin1String(":/translations")))
|
||||||
app.installTranslator(&translator);
|
QCoreApplication::installTranslator(&translator);
|
||||||
|
|
||||||
QPushButton hello(QCoreApplication::translate("main", "Hello world!"));
|
QPushButton hello(QCoreApplication::translate("main", "Hello world!"));
|
||||||
hello.resize(100, 30);
|
hello.resize(100, 30);
|
||||||
|
|
||||||
hello.show();
|
hello.show();
|
||||||
return app.exec();
|
return QCoreApplication::exec();
|
||||||
}
|
}
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user