Results 1 to 7 of 7

Thread: Can't style QHeaderView::section:selected in QSS stylesheet

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2009
    Posts
    49
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Can't style QHeaderView::section:selected in QSS stylesheet

    The title says it all: I seem unable to change the background color (or any other property) of a QHeaderView section using the QHeaderView::section:selected selector using Qt 4.7.0. Here's the relevant code:

    Qt Code:
    1. QHeaderView::section:selected
    2. {
    3. background-color: red;
    4. }
    To copy to clipboard, switch view to plain text mode 
    This is what I have now:

    QHeaderViewSectionSelectedBefore.png

    And this is what I would like to achieve (the selected section is highlighted):

    QHeaderViewSectionSelectedAfter.png

    According to the documentation, this ought to be possible:

    QHeaderView: Supports the box model. The sections of the header view are styled using the ::section sub control. The section Sub-control supports the :middle, :first, :last, :only-one, :next-selected, :previous-selected, :selected, and :checked pseudo states.
    Am I doing it right?

    (I couldn't find anything on that subject in the bug database, and I don't have Qt 4.8 handy to check if the behavior is different.)

    Cheers,
    Franz
    Last edited by dictoon; 15th January 2012 at 13:51.

Similar Threads

  1. Highlighting selected section on QDateTimeEdit
    By Yorma in forum Qt Programming
    Replies: 4
    Last Post: 3rd May 2013, 12:03
  2. Replies: 2
    Last Post: 10th August 2011, 07:16
  3. Stylesheet of selected item in combo-box
    By shrawan0786 in forum Qt Programming
    Replies: 1
    Last Post: 6th December 2010, 10:30
  4. QHeaderView: background of selected header item with CSS
    By antarctic in forum Qt Programming
    Replies: 5
    Last Post: 8th June 2009, 07:37
  5. QHeaderView section resizes
    By dimuz in forum Qt Programming
    Replies: 7
    Last Post: 11th October 2007, 16: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
  •  
Qt is a trademark of The Qt Company.