From a0f66d22cc2e74bb3dc4e49dc75be53c3e10fd60 Mon Sep 17 00:00:00 2001 From: Dieter Mayer Date: Sun, 12 Jul 2026 23:20:30 +0200 Subject: [PATCH] Fix remaining Qt6 build warnings (narrowing, nodiscard, qHash) Clears the 9 non-deprecation warnings from the Qt6 build: - qHash(QColor): hash rgba() (unambiguous QRgb) instead of name(), and use the size_t seed signature on Qt6 (guarded for Qt5). Fixes the ambiguous-overload warning in terminalstripmodel.h. - Two qsizetype->int narrowings in brace-init: explicit static_cast (elementscene.cpp, terminalstrip.cpp). - main.cpp: keep the QtConcurrent::run QFuture in a [[maybe_unused]] variable (nodiscard). - qetapp.cpp: guard the stylesheet load on QFile::open() succeeding (nodiscard) instead of ignoring the result. --- sources/TerminalStrip/terminalstrip.cpp | 2 +- sources/TerminalStrip/ui/terminalstripmodel.h | 10 ++++++++-- sources/editor/elementscene.cpp | 2 +- sources/main.cpp | 2 +- sources/qetapp.cpp | 9 +++++---- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/sources/TerminalStrip/terminalstrip.cpp b/sources/TerminalStrip/terminalstrip.cpp index 1775d0517..4094ccc83 100644 --- a/sources/TerminalStrip/terminalstrip.cpp +++ b/sources/TerminalStrip/terminalstrip.cpp @@ -639,7 +639,7 @@ bool TerminalStrip::isBridgeable(const QVector> &re // Get the physical terminal and pos auto first_physical_terminal = first_real_terminal->physicalTerminal(); QVector physical_vector{first_physical_terminal}; - QVector pos_vector{m_physical_terminals.indexOf(first_physical_terminal)}; + QVector pos_vector{static_cast(m_physical_terminals.indexOf(first_physical_terminal))}; auto bridge_ = isBridged(first_real_terminal); //bool to know at the end of this function if at least one terminal is not bridged diff --git a/sources/TerminalStrip/ui/terminalstripmodel.h b/sources/TerminalStrip/ui/terminalstripmodel.h index 4112af232..b29afc303 100644 --- a/sources/TerminalStrip/ui/terminalstripmodel.h +++ b/sources/TerminalStrip/ui/terminalstripmodel.h @@ -29,9 +29,15 @@ #include "modelTerminalData.h" //Code to use QColor as key for QHash -inline uint qHash(const QColor &key, uint seed) { - return qHash(key.name(), seed); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +inline size_t qHash(const QColor &key, size_t seed = 0) { + return qHash(key.rgba(), seed); } +#else +inline uint qHash(const QColor &key, uint seed) { + return qHash(key.rgba(), seed); +} +#endif //needed to use QPointer as key of QHash inline uint qHash(const QPointer &key, uint seed) { diff --git a/sources/editor/elementscene.cpp b/sources/editor/elementscene.cpp index bd2c9fdd4..a7a8cfebd 100644 --- a/sources/editor/elementscene.cpp +++ b/sources/editor/elementscene.cpp @@ -748,7 +748,7 @@ void ElementScene::addItems(QVector items) */ void ElementScene::removeItems(QVector items) { - const int previous_selected_count{selectedItems().size()}; + const int previous_selected_count = static_cast(selectedItems().size()); //block signal to avoid multiple emit of selection changed, //we emit this signal only once at the end of this function. diff --git a/sources/main.cpp b/sources/main.cpp index 9a86400ff..db3accc86 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -289,7 +289,7 @@ QGuiApplication::setHighDpiScaleFactorRoundingPolicy(QetSettings::hdpiScaleFacto // here guarantees the singleton is fully built before the worker runs. MachineInfo::instance(); - QtConcurrent::run([=]() + [[maybe_unused]] auto startup_future = QtConcurrent::run([=]() { // for debugging qInstallMessageHandler(myMessageOutput); diff --git a/sources/qetapp.cpp b/sources/qetapp.cpp index a19461e33..adac51c54 100644 --- a/sources/qetapp.cpp +++ b/sources/qetapp.cpp @@ -1697,10 +1697,11 @@ void QETApp::useSystemPalette(bool use) { ); } else { QFile file(configDir() + "/style.css"); - file.open(QFile::ReadOnly); - QString styleSheet = QLatin1String(file.readAll()); - qApp->setStyleSheet(styleSheet); - file.close(); + if (file.open(QFile::ReadOnly)) { + QString styleSheet = QLatin1String(file.readAll()); + qApp->setStyleSheet(styleSheet); + file.close(); + } } }