[Development] Qt 6: Assigning QPalette to ApplicationWindow.palette no longer supported?

Marcel Krems interceptor83 at gmx.de
Mon Aug 24 15:44:41 CEST 2020


Hi Fabian,

thanks for the feedback.

QGuiApplication::setPalette works mostly.
It doesn't allow me to change the theme/palette after the QML file has
been loaded (as mentioned here
https://doc.qt.io/qt-5/qml-qtquick-controls2-applicationwindow.html#palette-prop)
This approach also makes selecting the theme or editing and reloading
the theme impossible.
Also the ButtonText doen't use the new palette and stays black (I'm
using the Fusion theme).

I don't really mind the new way. I just wanted to know if I had to
change it or it might be working again later and I have changed it for
nothing
since it would be up to 60 properties (20 ColorRoles with 3 ColorGroups,
although I'll probably be ignoring the Inactive group).


I just tested the new QQuickPalette and I think I found a bug:
This works fine:
> palette{
> active{
> buttonText:Theme.buttonText
> }
> disabled{
> buttonText:Theme.buttonTextDisabled
> }
> }
But this does ignore the disabled text color:
> palette{
> buttonText:Theme.buttonText
> disabled{
> buttonText:Theme.buttonTextDisabled
> }
> }
And this also works:
> palette{
> buttonText:"orange"
> disabled{
> buttonText:Theme.buttonTextDisabled
> }
> }

Marcel


On 24.08.2020 14:23, Fabian Kosmale wrote:
> Hi Marcel,
>
> as Vitaly mentioned, palette was never explicitly documented to be a
> QPalette.
> We're currently discussing internally whether we still want to support
> binding a QPalette property
> to a palette QML property in Qt 6; and if yes, how to do it.
> We'll provide an update (+ justification) once we've come to a decision.
>
> What should work (both in 5.x and 6.0) is to use
> https://doc.qt.io/qt-5/qguiapplication.html#setPalette
> Does that functionality cover your use case?
>
>
> Fabian
>
>
> --
> Fabian Kosmale
> Software Engineer
>
> The Qt Company GmbH
> Erich-Thilo-Str. 10
> D-12489 Berlin
> fabian.kosmale at qt.io
> +49 1638686070
> http://qt.io
>
> Geschäftsführer: Mika Pälsi,
> Juha Varelius, Mika Harjuaho
> Sitz der Gesellschaft: Berlin,
> Registergericht: Amtsgericht
> Charlottenburg, HRB 144331 B
> --
> ------------------------------------------------------------------------
> *Von:* Development <development-bounces at qt-project.org> im Auftrag von
> Marcel Krems <marcel.k.dev at gmail.com>
> *Gesendet:* Freitag, 21. August 2020 22:24
> *An:* development at qt-project.org <development at qt-project.org>
> *Betreff:* [Development] Qt 6: Assigning QPalette to
> ApplicationWindow.palette no longer supported?
> 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
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20200824/8fee18af/attachment-0001.html>


More information about the Development mailing list