Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-115024

GnomeTheme colorScheme not being initialized



    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5.0
    • GUI: Look'n'Feel
    • None
    • Ubuntu 22.04.2 LTS
      Gnome Version 42.5
    • Linux/X11


      In qtbase/src/gui/platform/unix/qgenericunixthemes.cpp

      GnomeTheme colorScheme is not initalised.

      The value is set to Qt::ColorScheme::Unknown in the constructor, however, there is no initial read on this value before a GUI application is launch.

      A dbus connection is set up for watching the "SettingChanged" but not an initial read of the gtk theme.


      Apply the following patch to WidgetGallery example:

      --- a/./qtbase/examples/widgets/gallery/widgetgallery.cpp
      +++ b/./qtbase/examples/widgets/gallery/widgetgallery.cpp
      @@ -45,6 +45,8 @@
       #include <QTextStream>
       #include <QTimer>
      +#include <QStyleHints>
       static inline QString className(const QObject *o)
            return QString::fromUtf8(o->metaObject()->className());
      @@ -132,6 +134,14 @@ WidgetGallery::WidgetGallery(QWidget *parent)
      +    QStyleHints *hints = QApplication::styleHints();
      +    connect(hints, &QStyleHints::colorSchemeChanged,
      +            this, [this](Qt::ColorScheme colorScheme) {
      +            qDebug() << colorScheme;
      +            setPalette(qApp->style()->standardPalette());
      +            } );
           auto styleLabel = createWidget1<QLabel>(tr("&Style:"), "styleLabel");


      Example scenario: 

      1. Set Ubuntu to Dark-Mode via GUI.
      2. Build widget_gallery with Qt 6.5 with above patch
      3. Launch widget_gallery.

      Widget_gallery will open in "light" mode with color-scheme set to Qt::ColorScheme::Unknown.


      Opening "Appearance" in Ubuntu Settings will trigger "Setting Changed" and the widgets gallery will switch to Dark Mode.

      Switching to "light-mode" in Ubuntu Settings will toggle the widgets gallery back.


      But the initial system Settings for Dark Mode are ignored until the settings GUI is opened and "Appearance" is selected.


      The colorScheme value in GnomeTheme is missing an initial value being checked, unlike in the "refresh" function in the KdeTheme constructor.



        No reviews matched the request. Check your Options in the drop-down menu of this sections header.



            qt.team.quick.subscriptions Qt Quick and Widgets Team
            louspe-linaro Louise Spellacy
            0 Vote for this issue
            4 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes