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

Setting palette via Q_COREAPP_STARTUP_FUNCTION is broken if platform theme provides per-widget palettes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15, 6.5, 6.8, 6.9
    • Widgets: Styles
    • None

    Description

      KDE's KIconThemes framework sets palette in a Q_COREAPP_STARTUP_FUNCTION since KIconThemes 6.9 via KColorSchemeManager. This leads to the palette being partially applied, my investigation has pointed to QApplicationPrivate::initializeWidgetPalettesFromTheme() called by QApplicationPrivate::init() which overrides the palette for various widgets. QTimer::singleShot works as a workaround but would be nice if this was solved.

      A way to solve this is

      diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
      index 1a0ac0cc3cb..5537bdcc7fa 100644
      --- a/src/widgets/kernel/qapplication.cpp
      +++ b/src/widgets/kernel/qapplication.cpp
      @@ -1381,14 +1381,14 @@ void QApplicationPrivate::handlePaletteChanged(const char *className)
       
           // Palette has been reset back to the default application palette,
           // so we need to reinitialize the widget palettes from the theme.
      -    if (!className && !testAttribute(Qt::AA_SetPalette))
      +    if (!className)
               initializeWidgetPalettesFromTheme();
       }
       
       void QApplicationPrivate::initializeWidgetPalettesFromTheme()
       {
           QPlatformTheme *platformTheme = QGuiApplicationPrivate::platformTheme();
      -    if (!platformTheme)
      +    if (!platformTheme || testAttribute(Qt::AA_SetPalette))
               return;
       
           widgetPalettes.clear();
      

      Attachments

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

        Activity

          People

            tpochep Timur Pocheptsov
            ilya-fedin Ilya Fedin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes