From ec2ac17c10416d4f5a265f9899b8012d3bebea01 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 14 Apr 2020 09:59:14 +0200 Subject: Improve QTranslator documentation code snippet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use :/i18n/, because this is the place where translations are stored by default if using qmake's CONFIG += lrelease embed_translations. Also revert change of app.exec() done in 16da0b2cf8b6b. First of all, both QGuiApplication and QApplication feature overloads of exec(), so using QCoreApplication::exec() might miss functionality. Anyhow, while it's true that all of them are static member functions, the vast majority of our examples and templates call them with class member access syntax, so let's try to be consistent. Finally, the example since a while uses QCoreApplication::translate, not tr(), so let's not mention it in the description. Change-Id: Ic6e5d91cf04d3f0d1a4296c5c09e790773e6fc62 Reviewed-by: MiƂosz Kosobucki Reviewed-by: Paul Wicking --- src/corelib/doc/snippets/hellotrmain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib/doc') diff --git a/src/corelib/doc/snippets/hellotrmain.cpp b/src/corelib/doc/snippets/hellotrmain.cpp index 721a83240b..526da44701 100644 --- a/src/corelib/doc/snippets/hellotrmain.cpp +++ b/src/corelib/doc/snippets/hellotrmain.cpp @@ -54,15 +54,15 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); QTranslator translator; - // look up e.g. :/translations/myapp_de.qm - if (translator.load(QLocale(), QLatin1String("myapp"), QLatin1String("_"), QLatin1String(":/translations"))) + // look up e.g. :/i18n/myapp_de.qm + if (translator.load(QLocale(), QLatin1String("myapp"), QLatin1String("_"), QLatin1String(":/i18n"))) QCoreApplication::installTranslator(&translator); QPushButton hello(QCoreApplication::translate("main", "Hello world!")); hello.resize(100, 30); hello.show(); - return QCoreApplication::exec(); + return app.exec(); } //! [0] -- cgit v1.2.3