Results 1 to 9 of 9

Thread: Get checkbox of QStandardItem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Join Date
    Dec 2012
    Posts
    9
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Android
    Thanks
    3

    Default Re: Get checkbox of QStandardItem

    I managed to get by with the paint() method, but I'm kinda stuck with editorEvent(). Edit: I had a look at QItemDelegate source and found how to do it:
    Qt Code:
    1. bool CheckableItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
    2. {
    3. Q_UNUSED(option);
    4. if (event->type() == QEvent::MouseButtonRelease) {
    5. QVariant value = index.data(Qt::CheckStateRole);
    6. Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
    7. ? Qt::Unchecked : Qt::Checked);
    8. return model->setData(index, state, Qt::CheckStateRole);
    9. } else
    10. return false;
    11. }
    To copy to clipboard, switch view to plain text mode 

    This will intercept all mouse clicks on the item (and I'm ok with it).
    Last edited by Neptilo; 2nd December 2014 at 17:49.

Similar Threads

  1. Reimplemented QStandardItem
    By Miga in forum Qt Programming
    Replies: 6
    Last Post: 3rd April 2012, 15:48
  2. Replies: 4
    Last Post: 1st June 2011, 15:54
  3. setObjectName for QStandardItem
    By abk883 in forum Newbie
    Replies: 1
    Last Post: 20th May 2010, 19:20
  4. UTF8 and QStandardItem?
    By alexandernst in forum Newbie
    Replies: 17
    Last Post: 26th July 2009, 19:29
  5. QStandardItem question.
    By alexandernst in forum Qt Programming
    Replies: 6
    Last Post: 21st July 2009, 02:01

Tags for this Thread

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.