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

Incorrect colour name returned when handling colorSchemeChanged

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5.0
    • GUI: Other
    • None
    • Windows 11 22H2
    • Windows

    Description

      I have a class that initialises a colour name in the ctor initialiser list:

       

      windowColourName{ palette().color(QPalette::ColorRole::Window).name()}, // Default base window colour
      {{}}
       
      

      If the active windows theme is a Light theme it is set to "#f0f0f0" at that point.

      If the active windows theme is a Dark theme it is set to "#1e1e1e"

      If I switch themes, I enter this code:

      void ExplorerBar::onColorSchemeChanged(Qt::ColorScheme scheme)
      {
      //
      // Dark colour scheme?
      //
      if (Qt::ColorScheme::Dark == scheme)
      activeGroupColourName = "darkcyan";
      else
      activeGroupColourName = "lightcyan";
      windowColourName = palette().color(QPalette::ColorRole::Window).name(); // Default base window colour
      const auto tabID = dssApp->tab();
      if (IDD_REGISTERING == tabID)
      { 
      ui->registerAndStack->setStyleSheet(QString("background-color: %1").arg(activeGroupColourName)); ui->processing->setStyleSheet(QString("background-color: %1").arg(windowColourName)); }
      else
      {
      ui->registerAndStack->setStyleSheet(QString("background-color: %1").arg(windowColourName));
      ui->processing->setStyleSheet(QString("background-color: %1").arg(activeGroupColourName));
      }
      ui->options->setStyleSheet(QString("background-color: %1").arg(activeGroupColourName));
      makeLinks();
      }
      

      My problem is that the line that sets windowColourName is returning #1e1e1e when switching to a light theme from a Dark theme, or #f0f0f0 when switching the other way.  

      Attachments

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            perdrix David Partridge
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: