[Development] Qt 6: Assigning QPalette to ApplicationWindow.palette no longer supported?
Vitaly Fanaskov
vt4a2hqt at gmail.com
Mon Aug 24 13:41:22 CEST 2020
Hi Marcel,
> Is my use case no longer supported or is this a regression?
I don't think that this is a regression. Because the code you mentioned
relies on knowledge from the private headers. Please, correct me if I'm
mistaken, but it's not mentioned in the official documentation that palette
from QML is QPalette.
Qt developers always try to reduce inconvenience even for transitions
between major releases. Unfortunately, it's not always possible.
> 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?
Well, I have no answer for a compatible solution. Only something in C++
involved using private headers, but I wouldn't recommend it.
The solution for QML looks good at a glance.
Vitaly
On Fri, Aug 21, 2020 at 10:26 PM Marcel Krems <marcel.k.dev at gmail.com>
wrote:
> 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
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development
>
--
Vitaly Fanaskov | Software Engineer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20200824/9cf0342e/attachment.html>
More information about the Development
mailing list