> On 28 Jul 2026, at 02:10, Thiago Macieira <[email protected]> wrote:
>
> On Monday, 27 July 2026 04:50:49 Pacific Daylight Time Volker Hilsheimer via
> Development wrote:
>> Ok; it then seems reasonable for the next step to be a cleaning up of
>> in-tree code, see what we can learn from that (if anything; tests can
>> perhaps get away with s/path()/paths().first()?), and only deprecate once
>> we have a clean source tree ourselves and a good porting guideline.
>
> The libraries are already all free of it.
>
> The problem are examples and tests. I asked the question because I noticed
> just how much there is of it and I don't intend to fix them all.
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.
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.
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?
Volker
--
Development mailing list
[email protected]
https://lists.qt-project.org/listinfo/development