Results 1 to 2 of 2

Thread: using drawCheck() to customize checkbox in QTableView

  1. #1
    Join Date
    Feb 2009
    Posts
    11
    Thanks
    4
    Qt products
    Platforms
    Unix/X11 Windows

    Default using drawCheck() to customize checkbox in QTableView

    Hi folks,
    My QTableView is shown in the picture below. As you see the Online column and the Locked column are checkable.

    But what I'm having difficulty with is how to customize the check indicator. I want my QTableView like what is shown in the following picture (it's gimped):

    As you already might have guessed, I should implement this protected function in my delegate:
    Qt Code:
    1. void QItemDelegate::drawCheck ( QPainter * painter, const QStyleOptionViewItem & option, const QRect & rect, Qt::CheckState state ) const
    To copy to clipboard, switch view to plain text mode 
    As you can see, I want to show two different images (actually four) considering which column is being rendered. But drawCheck doesn't provide any argument which shows which column is being rendered (like a QModelIndex).

  2. #2
    Join Date
    Feb 2009
    Posts
    11
    Thanks
    4
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: using drawCheck() to customize checkbox in QTableView

    I created two separate subclass from QItemDelegate and it's working fine I used QAbstractItemView::setItemDelegateForColumn() method.
    Thanks!

Similar Threads

  1. QTableView checkbox center with stylesheet
    By quiet in forum Qt Programming
    Replies: 2
    Last Post: 10th March 2011, 13:52
  2. boolean field checkbox QTableView
    By skuda in forum Qt Programming
    Replies: 4
    Last Post: 8th November 2010, 13:48
  3. Replies: 1
    Last Post: 6th July 2009, 01:53
  4. QTableView with a checkbox
    By maxpower in forum Qt Programming
    Replies: 17
    Last Post: 18th February 2007, 09:45
  5. CheckBox and selection in QTableView
    By Mike Krus in forum Qt Programming
    Replies: 1
    Last Post: 21st September 2006, 20:31

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.