Results 1 to 4 of 4

Thread: Problem with QHeaderView pseudo-states and stylesheets

  1. #1
    Join Date
    Jun 2011
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    4

    Default Problem with QHeaderView pseudo-states and stylesheets

    Hi !
    I'm currently working on a QHeaderView, styling it with a stylesheet. I'm almost done, i just can't find the way to set a background-color to the QHeader::section used for sorting...

    In the Qt doc (here), I found this example:

    Qt Code:
    1. QHeaderView::section:checked
    2. {
    3. background-color: red;
    4. }
    To copy to clipboard, switch view to plain text mode 

    I tried it but the :checked pseudo-state does not seem to do anything.
    What does it do ??
    Is there a way to achieve my goal ?

    Thanks,
    Marwyn

  2. #2
    Join Date
    Jun 2011
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    4

    Default Re: Problem with QHeaderView pseudo-states and stylesheets

    Still stuck with my problem...

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,345
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: Problem with QHeaderView pseudo-states and stylesheets

    It doesn't look like the style sheet supports a different background color for the sort section. The ":checked" pseudo-state has nothing to do with sorting as far as I can tell. The only features available in the style sheet concerning sorting are the ::up-arrow and ::down-arrow.

    If you override the QHeaderView:: paintSection() method, you can test to see if the logicalSection argument matches the sortIndicatorSection() and set a different background brush.

    What you want to do is non-standard behaviour for tables. In general, the standard approach is to use the sort indicator to show which column is the sort column and in which direction it is sorted.

  4. #4
    Join Date
    Jun 2011
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    4

    Default Re: Problem with QHeaderView pseudo-states and stylesheets

    mhhh
    I wanted to avoid overriding the paintSection()... But if this is the only way i guess I have no choice.

    Thx anyway ^^

    PS: still don't know what ":checked" do...

Similar Threads

  1. Problem: Transparent Background with Stylesheets
    By dropkickz in forum Qt Programming
    Replies: 2
    Last Post: 7th June 2011, 11:58
  2. resize problem with QHeaderView using qt4.5.3
    By drawat in forum Qt Programming
    Replies: 0
    Last Post: 4th August 2010, 09:42
  3. Problem with QAbstractSocket and states.
    By nomadscarecrow in forum Qt Programming
    Replies: 0
    Last Post: 17th March 2010, 16:55
  4. Replies: 4
    Last Post: 9th April 2009, 23:49
  5. Problem mit Stylesheets
    By momesana in forum Qt Programming
    Replies: 1
    Last Post: 10th November 2006, 21:41

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
  •  
Qt is a trademark of The Qt Company.