Results 1 to 2 of 2

Thread: Changing the color of the selection in a QListWidget

  1. #1
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Changing the color of the selection in a QListWidget

    Hi! How do I change the color of the selection of a QListWidget? I came up with this but it doesn't work:

    Qt Code:
    1. QPalette p = QPalette(skinsListView->palette());
    2. p.setColor(QPalette::Highlight, QColor(22, 22, 123));
    3. skinsListView->setPalette(p);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Changing the color of the selection in a QListWidget

    try QListWidgetItem::setBackground()
    http://doc.trolltech.com/4.6/qlistwi...#setBackground
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Item Selection in QListWidget
    By mclark in forum Qt Programming
    Replies: 2
    Last Post: 12th February 2008, 15:53
  2. QListWidget multi selection
    By user in forum Qt Programming
    Replies: 1
    Last Post: 6th February 2008, 07:36
  3. QTreeWidget & QListWidget different selection
    By munna in forum Qt Programming
    Replies: 9
    Last Post: 21st July 2006, 06:50
  4. QListWidget selection behavior
    By Arthur in forum Qt Programming
    Replies: 1
    Last Post: 30th May 2006, 14:10
  5. Replies: 3
    Last Post: 12th April 2006, 09:35

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.