diff options
author | Kai Köhne <kai.koehne@qt.io> | 2021-06-13 14:28:53 +0200 |
---|---|---|
committer | Kai Köhne <kai.koehne@qt.io> | 2021-06-21 13:39:50 +0200 |
commit | 0fd4f2a8def276aab0cb6465ba7b9ce75beb3a86 (patch) | |
tree | 8b487cfa1f4186b4e86f1305a83a66186b30c654 /examples/assistant/simpletextviewer | |
parent | 6db694453636a0f7b8c4f51048f352da80d912d2 (diff) |
Examples: Don't use QDir::separator() in internal paths
Documentation says:
You do not need to use this function to build file paths.
If you always use "/", Qt will translate your paths to conform
to the underlying operating system.
Change-Id: Iba62a197821b9abc819c3d333e44c9f1ed989898
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
(cherry picked from commit 8329ec476b3dc9bb7ffd17ee724b6b21c17e90ec)
Diffstat (limited to 'examples/assistant/simpletextviewer')
-rw-r--r-- | examples/assistant/simpletextviewer/assistant.cpp | 9 | ||||
-rw-r--r-- | examples/assistant/simpletextviewer/findfiledialog.cpp | 4 |
2 files changed, 7 insertions, 6 deletions
diff --git a/examples/assistant/simpletextviewer/assistant.cpp b/examples/assistant/simpletextviewer/assistant.cpp index ceda2c384..f6d7d3d33 100644 --- a/examples/assistant/simpletextviewer/assistant.cpp +++ b/examples/assistant/simpletextviewer/assistant.cpp @@ -115,11 +115,11 @@ bool Assistant::startAssistant() } if (m_process->state() != QProcess::Running) { - QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator(); + QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath); #ifndef Q_OS_DARWIN - app += QLatin1String("assistant"); + app += QLatin1String("/assistant"); #else - app += QLatin1String("Assistant.app/Contents/MacOS/Assistant"); + app += QLatin1String("/Assistant.app/Contents/MacOS/Assistant"); #endif const QString collectionDirectory = documentationDirectory(); @@ -135,7 +135,8 @@ bool Assistant::startAssistant() m_process->start(app, args); if (!m_process->waitForStarted()) { - showError(tr("Unable to launch Qt Assistant (%1): %2").arg(app, m_process->errorString())); + showError(tr("Unable to launch Qt Assistant (%1): %2") + .arg(QDir::toNativeSeparators(app), m_process->errorString())); return false; } } diff --git a/examples/assistant/simpletextviewer/findfiledialog.cpp b/examples/assistant/simpletextviewer/findfiledialog.cpp index 1eab5ad7f..51b184075 100644 --- a/examples/assistant/simpletextviewer/findfiledialog.cpp +++ b/examples/assistant/simpletextviewer/findfiledialog.cpp @@ -112,9 +112,9 @@ void FindFileDialog::openFile() return; QString fileName = item->text(0); - QString path = directoryComboBox->currentText() + QDir::separator(); + QString path = QDir(directoryComboBox->currentText()).filePath(fileName); - currentEditor->setContents(path + fileName); + currentEditor->setContents(path); close(); } |