Fix discard and deprecation warnings - #869
Open
kriben wants to merge 2 commits into
Open
Conversation
Fixes -Wunused-result warnings with GCC 15, since QFile::open is marked nodiscard in Qt 6. Stylesheets in the dock manager and the demo are now only read when the file was opened successfully; a missing file still results in an empty stylesheet as before.
…teWindow QApplication::setActiveWindow is deprecated since Qt 6.5 and produces a -Wdeprecated-declarations warning. QWidget::activateWindow is available in both Qt 5 and Qt 6 and is the recommended replacement.
kriben
force-pushed
the
fix-discard-and-deprecation-warnings
branch
from
September 4, 2026 11:40
8f03f9e to
aef3086
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix compiler warnings with GCC 15 / Qt 6.10
Building the library and demo with GCC 15.2 and Qt 6.10.2 produces a few warnings. This PR fixes them in two small commits.
Check return value of
QFile::openwhen loading stylesheetsQFile::openis markednodiscardin Qt 6, so ignoring its result triggers-Wunused-result. The stylesheet loading inCDockManager, the demo'smain.cppandCMainWindow::applyVsStylenow only read the file when it was opened successfully. Behaviouris unchanged: a missing file still results in an empty stylesheet.
Replace deprecated
QApplication::setActiveWindowwithQWidget::activateWindowQApplication::setActiveWindowis deprecated since Qt 6.5 and triggers-Wdeprecated-declarations.QWidget::activateWindowis therecommended replacement and is available in both Qt 5 and Qt 6, so no version guard is needed.
After these changes the library, all examples and the demo build without warnings, also with
-Wall -Wextra.