Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Handling colorSchemeChanged
Forum Updated to NodeBB v4.3 + New Features

Handling colorSchemeChanged

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 702 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by Perdrix
    #1

    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.

    What do I need to call to ensure I pick up the updated window colour?

    Thanks
    David

    SGaistS 1 Reply Last reply
    0
    • PerdrixP Perdrix

      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.

      What do I need to call to ensure I pick up the updated window colour?

      Thanks
      David

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You should add which OS you are getting this behaviour on.

      Just a guess, but Qt 6.5.0 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      PerdrixP 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        You should add which OS you are getting this behaviour on.

        Just a guess, but Qt 6.5.0 ?

        PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote on last edited by
        #3

        @SGaist Sorry, 6.5.0 Windows 11 22H2

        PerdrixP 1 Reply Last reply
        0
        • PerdrixP Perdrix

          @SGaist Sorry, 6.5.0 Windows 11 22H2

          PerdrixP Offline
          PerdrixP Offline
          Perdrix
          wrote on last edited by Perdrix
          #4

          I've reported this as a bug ...

          https://bugreports.qt.io/browse/QTBUG-112653

          Thanks
          David

          SGaistS 1 Reply Last reply
          0
          • PerdrixP Perdrix

            I've reported this as a bug ...

            https://bugreports.qt.io/browse/QTBUG-112653

            Thanks
            David

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            You should add a minimal compilable project to the bug report.

            That will make things easier to test and reproduce.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            PerdrixP 1 Reply Last reply
            0
            • SGaistS SGaist

              You should add a minimal compilable project to the bug report.

              That will make things easier to test and reproduce.

              PerdrixP Offline
              PerdrixP Offline
              Perdrix
              wrote on last edited by
              #6

              @SGaist Further digging has determined that the Palette colours are NOT BEING UPDATED AT ALL when the theme is changed.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved