Results 1 to 4 of 4

Thread: About the background color of QTreeView itmes

  1. #1
    Join Date
    Mar 2009
    Location
    China
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question About the background color of QTreeView itmes

    Is there anyone knows how to set the background color of different itmes in QTreeView?Thanks very much

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: About the background color of QTreeView itmes

    in general you can use Qt::BackgroundRole, but if you use QStandardItemMode & QStandardItem then you can use this method QStandardItem::setBackground or you also can create your own delegate and reimplement QItemDelegate::drawBackground.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: About the background color of QTreeView itmes

    another way would be to use stylesheet. The following should work:

    QTreeView::item
    {
    background-color: #your color
    }

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: About the background color of QTreeView itmes

    If you want to use background color to differentiate items, you can also have a look at QAbstractItemView::setAlternatingRowColors

Similar Threads

  1. background image in QTreeView
    By momesana in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2007, 06:25

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.