Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Active/Inactive background colour switching
Qt 6.12 LTS is out! See what's new in the release blog

Active/Inactive background colour switching

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 974 Views 2 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
    #1

    I have setup a Palette for a groupbox as follows:

    QPalette palette;
    QBrush brush(QColor(217, 224, 240, 255));
    brush.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::Active, QPalette::Window, brush);
    QBrush brush1(QColor(240, 240, 240, 255));
    brush1.setStyle(Qt::SolidPattern);
    palette.setBrush(QPalette::Inactive, QPalette::Window, brush1);
    palette.setBrush(QPalette::Disabled, QPalette::Window, brush1);
    groupbox.setPalette(palette);
    

    How do I get the groupbox to switch between the Active and Inactive colours? Clicking on it doesn't seem to do much.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      From memory, inactive is for when the container widget is inactive. Usually when another window or application has the focus.

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

      1 Reply Last reply
      1
      • PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote on last edited by
        #3

        In the end I gave up on that approach and did this:

        oid ExplorerBar::mousePressEvent(QMouseEvent *event)
        {
        	if (Qt::LeftButton == event->buttons())
        	{
        		const auto dwTabID = dssApp->tab();
        		if ((ui->registerAndStack->underMouse()) && (dwTabID != IDD_REGISTERING) && (dwTabID != IDD_STACKING))
        		{
        			ui->registerAndStack->setStyleSheet("background-color: lightcyan");
        			ui->processing->setStyleSheet("background-color: rgb(240, 240, 240)");
        			// Change tab to stacking
        			dssApp->setTab(IDD_STACKING);
        		}
        		else if (ui->processing->underMouse() && (dwTabID != IDD_PROCESSING))
        		{
        			ui->registerAndStack->setStyleSheet("background-color: rgb(240, 240, 240)");
        			ui->processing->setStyleSheet("background-color: lightcyan");
        			// Change tab to processing
        			dssApp->setTab(IDD_PROCESSING);
        		};
        	}
        	Inherited::mousePressEvent(event);
        }
        
        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
        • Unsolved