Skip to content

Fix qt and c++ warnings#1001

Merged
kaamui merged 7 commits intoOpenBoard-org:devfrom
Vekhir:fix-qt6-warnings
Aug 14, 2024
Merged

Fix qt and c++ warnings#1001
kaamui merged 7 commits intoOpenBoard-org:devfrom
Vekhir:fix-qt6-warnings

Conversation

@Vekhir
Copy link
Copy Markdown
Contributor

@Vekhir Vekhir commented Jun 6, 2024

Similar warnings are grouped into commits. If there are questions or suggestions, you may comment below, so we can discuss them. The solutions are based on the compiler recommendations.

Where changes cannot be made cross-compatible, they are version gated (mostly concerns Qt 6 vs Qt 5). Some warnings remain that are a bit more involved (mainly around FFmpeg and OpenSSL/MD5).

Run on Arch Linux with Qt 6.7.1 and C++20 on GCC 14.1.1.

Vekhir added 7 commits June 6, 2024 11:10
setNamedColor is deprecated starting with Qt 6.4.

There is one instance where `colorOnLightBackground` is redefined
in a separate scope, making it a noop. This has been corrected.
Qt provides qAsConst to avoid detaching and thus reduce copying.
C++17 introduces std::as_const which has the same effect and is
the recommended replacement by Qt.
Git history doesn't go far enough to determine why this call exists;
it's at least 13 years old. This section of code hasn't ever changed.
It's reasonable to assume that it's a typo (maybe first implementation
attempt) and the compiler just didn't warn about it, so it was
overlooked.
Now the compiler warns about it.
Calling `reserve()` without arguments is deprecated in C++20. It
is equivalent to `shrink_to_fit()` which is also available in
C++17.
QString::count() without arguments is deprecated with Qt 6.4.
count() is equivalent to size() and length(); the latter is chosen
as replacement. It conveys a sense of ordering.
`associatedWidgets` is deprecated since Qt 6.0. Qt 6.0 instead
introduced `associatedObjects` which more generally returns QObject
rather than QWidget.
The remaining logic stays the same, using qobject_cast to get the
correct instances. For simplicity, the variable names stay unchanged.
Qt 6.0 changed to QSinglePointEvent and thus has a changed interface.
In particular, the pos() function has been renamed to position().
Qt 6.4 deprecates the constructor for QMouseEvent without global
positioning, so add the global position to the constructor.
@letsfindaway
Copy link
Copy Markdown
Collaborator

letsfindaway commented Jun 7, 2024

To check compatibility of this patch with various versions of gcc, ffmpeg and Qt, I created a project on the openSUSE build service to build the current dev branch together with this PR for Qt5 and Qt6 and a range of Arch, Debian, openSUSE and Ubuntu versions. The results show no conflicts with any of these distribution versions.

The unresolvable for the Qt6 build with Debian Unstable is not caused by this PR, but by the transition of Debian to t64 packages mitigating the 32bit time problem for 32-bit builds. It is not relevant here for this check.

So my conclusion: I support merging this PR, as it removes deprecations and improves compatibility with current and future Qt versions.

Copy link
Copy Markdown
Collaborator

@letsfindaway letsfindaway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also reviewed the changes manually and did not find any problems. I therefore approve this PR.

@Vekhir
Copy link
Copy Markdown
Contributor Author

Vekhir commented Jun 7, 2024

@letsfindaway Thanks for having a look. While testing on my system, I've made sure to be as compatible as possible and keep the changes small. Great to see that the documentation for Qt and C++ is actually accurate 😄

@kaamui kaamui merged commit c8d6d70 into OpenBoard-org:dev Aug 14, 2024
@Vekhir Vekhir deleted the fix-qt6-warnings branch August 14, 2024 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants