[Development] Qt 6: Assigning QPalette to ApplicationWindow.palette no longer supported?
Marcel Krems
marcel.k.dev at gmail.com
Fri Aug 21 22:24:18 CEST 2020
Hi,
I recently implemented a theming system for my Qt Quick application.
With Qt 6 I'm getting an error: "Unable to assign QPalette to
QQuickPalette*"
This was changed in the following commits:
- https://codereview.qt-project.org/c/qt/qtquickcontrols2/+/270097
- https://codereview.qt-project.org/c/qt/qtdeclarative/+/270092
My Theme class looks like this:
class Theme : public QObject
{
Q_OBJECT
Q_PROPERTY(QPalette palette MEMBER _palette NOTIFY themeChanged)
...
};
In my main.qml I'm setting the palette with:
ApplicationWindow {
palette: Theme.palette
...
}
My question is:
Is my use case no longer supported or is this a regression?
And if not, what is the proposed way to do it? Preferrably compatible
with Qt 5.15 and Qt 6.
Do I have to set every single colorrole of the palette separately?
E.g.
ApplicationWindow {
palette {
active {
buttonText: Theme.buttonText
button: Theme.button
...
}
disabled {
buttonText: Theme.buttonTextDisabled
button: Theme.buttonDisabld
}
}
}
Kind regards,
Marcel
More information about the Development
mailing list