On Tuesday, 28 July 2026 02:08:24 Pacific Daylight Time Volker Hilsheimer via 
Development wrote:
> Getting the examples cleaned up is IMHO a precondition for deprecating, and
> the tests should disable the deprecation warning as otherwise we get
> -Werror build failures. The examples are a fairly overviewable list, but
> they should of course show the right pattern.

We get warnings in tests, not errors. Tests are compiled without -Werror.

> So the question is what the correct replacement for code like this is:
> 
>     // from qtbase/examples/corelib/mimetypes/mimetypebrowser/main.cpp
>     QTranslator translator;
>     if (translator.load(QLocale::system(), "qtbase"_L1, "_"_L1,
>                         QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
> { app.installTranslator(&translator);
>     }
> 
> 
> I assume the right pattern is using a while-loop until one of the loads
> succeeded, rather than loading them all in a for-loop.

Now that you mentioned it, that one in particular deserves more thought. There 
is a lot of code doing exactly the same and one QTranslator can only load one 
translation.

So, first, we should probably add functions to QTranslator and/or 
QStandardPaths to find the translations so we don't have to deploy the looping. 
Second, we should investigate whether QTranslator should be able to keep 
multiple translation files: if we can have multiple translation files, can more 
than one of them contain content? And if so, are they additive or do they 
replace?

> Esp when looking at:
> 
>     // from qttools/examples/assistant/remotecontrol/remotecontrol.cpp
>     QString app = QLibraryInfo::path(QLibraryInfo::BinariesPath);
> #if !defined(Q_OS_MACOS)
>     app += "/assistant"_L1;
> #else
>     app += "/Assistant.app/Contents/MacOS/Assistant"_L1;
> #endif
> 
>     process->start(app, {"-enableRemoteControl"_L1});
>     if (!process->waitForStarted()) {
>         QMessageBox::critical(this, tr("Remote Control"),
>                 tr("Could not start Qt Assistant from
> %1.").arg(QDir::toNativeSeparators(app))); return;
>     }
> 
> 
> Launching several assistants would be a surprise.
> 
> Perhaps a naive
> 
>     QString app = QLibraryInfo::paths(QLibraryInfo::BinariesPath).first();
> 
> is fine, as long as paths() guarantees that there is always at least one
> entry. But is it a practice we want to encourage?

Same as above: it seems to me we want a locate() API like QStandardPaths.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Principal Engineer - Intel DCG - Platform & Sys. Eng.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

-- 
Development mailing list
[email protected]
https://lists.qt-project.org/listinfo/development

Reply via email to