Qt 6 - Windows issues loading dis-/enabled tool buttons (fix for #4077) #4078
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.
This PR fixes #4077
I doubled checked it with the old Qt 5 build and dis-/enabling tool buttons worked on Windows. With Qt 6 loading the saved configuration didn't work anymore and debug console output was showing: "QVariant::load: unknown user type with name QList."
There must have been changes in the Qt meta-type system and platform-specific differences. QList is not a built-in QVariant type. To use custom types we need to register them using Q_DECLARE_METATYPE(QList) and qRegisterMetaType<QList>().
In Qt 5, handling of QList was more permissive, so QList sometimes worked without explicit registration. Starting with Qt 6, the meta-type system has become stricter and does not recognize QList natively anymore. This causes the type to be unknown when deserializing (e.g. from QSettings), unless explicitly registered.
I couldn't find clear explanation for the differences on Windows and Linux, but AI mentioned: "The Qt build configuration or available precompiled meta-types can differ between Windows and Linux, which is why the problem only appears on one platform."
I tested this PR on Windows and on Manjaro and it worked on both systems, so I'd say we don't need explicit
#if defined(Q_OS_WIN)
.