Results 1 to 6 of 6

Thread: Change appearence of selected row in QTableView

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    80
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Change appearence of selected row in QTableView

    Working with a delegate is a good idea as sugested by MrDeath, here is an example:

    Qt Code:
    1. void
    2. MouradDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& i ) const
    3. {
    4. if (option.showDecorationSelected && (option.state & QStyle::State_Selected)){
    5. if (option.state & QStyle::State_Active)
    6. // Mourad place here whatever you would like to see when the row is selected and active
    7. painter->fillRect(option.rect, option.palette.highlight().color());
    8. else {
    9. // Mourad place here whatever you would like to see when the row is selected but not active
    10. QPalette p=option.palette;
    11. painter->fillRect(option.rect, p.color(QPalette::Inactive, QPalette::Background));
    12. }
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to schall_l for this useful post:

    Finrond (15th February 2013)

Similar Threads

  1. Remove selected rows from a QTableView
    By niko in forum Qt Programming
    Replies: 4
    Last Post: 3rd March 2016, 12:49
  2. How to change columns order in a QTableView...
    By cydside in forum Qt Programming
    Replies: 1
    Last Post: 20th April 2009, 10:42
  3. How to display selected columns in QTableView widget.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 08:30
  4. QGraphicsView : change selected rectangle style
    By kghose in forum Qt Programming
    Replies: 2
    Last Post: 28th July 2008, 18:12
  5. iterating selected rows in a qtableview
    By JeanC in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2008, 14:29

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.