Results 1 to 2 of 2

Thread: Changing the inactive palette to an active palette in a QTreeWidget doesn't work?

  1. #1
    Join Date
    Nov 2012
    Posts
    21
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Changing the inactive palette to an active palette in a QTreeWidget doesn't work?

    I want my QTreeWidget to have the same text highlighting when it is inactive as when it is active. So I did:

    Qt Code:
    1. QPalette p = palette();
    2. p.setColor(QPalette::Inactive, QPalette::Highlight, p.color(QPalette::Active, QPalette::Highlight));
    3. p.setColor(QPalette::Inactive, QPalette::HighlightedText, p.color(QPalette::Active, QPalette::HighlightedText));
    4. setPalette(p);
    To copy to clipboard, switch view to plain text mode 

    It did nothing. So I tried:
    Qt Code:
    1. QPalette p = palette();
    2. for (int colorRole=0; colorRole < QPalette::NColorRoles; colorRole++)
    3. {
    4. QPalette::ColorRole role = static_cast<QPalette::ColorRole>(colorRole);
    5. p.setColor(QPalette::Inactive, role, p.color(QPalette::Active, role));
    6. }
    7. setPalette(p);
    To copy to clipboard, switch view to plain text mode 

    It also didn't work. I have also tried setting the palette on the viewport and had a quick look to see whether I'm supposed to set it on the delegate (but the delegate doesn't have a palette). This seemingly 5 minute task is now chewing up hours. Does anybody know what I have to do make it so that my inactive and active highlights on a QTreeWidget are the same?

  2. #2
    Join Date
    Feb 2014
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Changing the inactive palette to an active palette in a QTreeWidget doesn't work?

    Have you tryed setting up the stylesheet on the QTreeWidget?? Something like:

    QTreeWidget::item:active {background-color: rgb(30, 30, 30);
    selection-background-color: rgb(30, 30, 30);}

    QTreeWidget::item:inactive {background-color: rgb(30, 30, 30);
    selection-background-color: rgb(30, 30, 30);}

    or eve setting the selection-background-color to any color with alpha 0 (ex rgba(30, 30, 30,0))?

Similar Threads

  1. Replies: 0
    Last Post: 4th March 2011, 20:18
  2. Problems with the palette on the Mac
    By JohnGaby in forum Qt Programming
    Replies: 0
    Last Post: 6th March 2010, 14:59
  3. Qt custom Palette
    By bunjee in forum Qt Programming
    Replies: 3
    Last Post: 23rd January 2009, 22:46
  4. Changing application palette [solved]
    By maverick_pol in forum Qt Programming
    Replies: 1
    Last Post: 2nd April 2008, 17:02
  5. Setting QFrame palette in Designer doesn't "stick"
    By Doug Broadwell in forum Qt Tools
    Replies: 1
    Last Post: 9th September 2007, 22:44

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.