Results 1 to 2 of 2

Thread: How do i change background of QTableView cells

  1. #1
    Join Date
    Jul 2010
    Posts
    30
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default How do i change background of QTableView cells

    Hello
    i want to have a filtering system for my big table view that is populated from a database . i have a line edit and i can obtain tableview indexes that contain line edit's text but how do i change the QModelIndexList items' backgrounds ?
    thanks
    Impossible = I'mpossible

  2. #2
    Join Date
    Jul 2010
    Posts
    41
    Thanks
    6
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How do i change background of QTableView cells

    Every item has a widget, just set the background for that.
    Qt Code:
    1. //'index' is 'QModelIndex' for item
    2. //'table' is 'QTableView *' instance
    3. //'PIXMAP_PATH' is your background image path
    4. QWidget *widget = table->indexWidget( index );
    5. QPalette p( widget->palette());
    6. p.setBrush(QPalette::Base, QBrush(QPixmap(PIXMAP_PATH)) );
    7. widget->setPalette(p);
    8. table->setIndexWidget( index, widget );
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Can't edit my QTableView cells
    By MattPhillips in forum Newbie
    Replies: 4
    Last Post: 2nd February 2011, 13:49
  2. Replies: 2
    Last Post: 11th March 2009, 02:00
  3. Lists/multiline text in QTableView cells
    By dv_ in forum Qt Programming
    Replies: 1
    Last Post: 22nd June 2008, 23:43
  4. Text in QTableView cells not visible
    By juliarg in forum Newbie
    Replies: 2
    Last Post: 22nd March 2007, 15:49
  5. Editable cells in QTableView
    By TheRonin in forum Qt Programming
    Replies: 1
    Last Post: 29th November 2006, 17:39

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.