Results 1 to 5 of 5

Thread: Background color for rows in a QTableWidget: How to do that?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,315
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Background color for rows in a QTableWidget: How to do that?

    These are two different questions. QTableView and QTableWidget use different methods for setting the background color for rows.

    For QTableWidget, when you add or modify the QTableWidgetItem(s) in the rows, you set the color using QTableWidgetItem::backgroundBrush().

    If you are using QTableView with a QAbstractItemModel (or proxy), you implement the Qt::BackgroundRole role in the QAbstractItemModel::data() method to set the QBrush used to fill the cells in the row with the appropriate color.

  2. #2
    Join Date
    Mar 2015
    Posts
    16
    Thanks
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Background color for rows in a QTableWidget: How to do that?

    Hi d_strantz,

    OK, good to know!
    Give it a google & try

  3. #3
    Join Date
    Mar 2015
    Posts
    16
    Thanks
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Background color for rows in a QTableWidget: How to do that?

    Thanks, that did the trick for me
    /a

Similar Threads

  1. QTableWidget alternating background color
    By Aslan in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2014, 07:32
  2. Replies: 4
    Last Post: 17th July 2010, 04:47
  3. Setting background colors to rows in QTableWidget
    By cnbp173 in forum Qt Programming
    Replies: 0
    Last Post: 24th April 2009, 17:38
  4. Replies: 1
    Last Post: 23rd March 2009, 21:36
  5. QTableWidget Background Color
    By mbrusati in forum Qt Programming
    Replies: 2
    Last Post: 23rd September 2008, 18:38

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.