Results 1 to 6 of 6

Thread: Checkboxes in QAbstractITemModel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Checkboxes in QAbstractITemModel

    If you do this:
    Qt Code:
    1. void ModelTestModel::clicked( const QModelIndex& index )
    2. {
    3. if( index.column() == 0 ){
    4. ModelTestModelItem *item = static_cast< ModelTestModelItem* >( index.internalPointer() );
    5.  
    6. if( item->checkState() == Qt::Checked )
    7. item->setCheckState( Qt::Unchecked );
    8. else
    9. item->setCheckState( Qt::Checked );
    10.  
    11. _parent->update( index );
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 
    then no wonder a click on the whole area makes the item checked. There is no need for such things. The checkable functionality is provided out of the box by the framework. For you it doesn't work, because you didn't implement setData(). If you do and handle changing the Qt::CheckStateRole, it will work as expected.

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

    Valheru (28th November 2007)

Similar Threads

  1. Displaying windows depending on checkboxes
    By Salazaar in forum Newbie
    Replies: 1
    Last Post: 12th May 2007, 19:42
  2. Displaying QAbstractItemModel in a Table
    By bmesing in forum Qt Programming
    Replies: 1
    Last Post: 28th March 2007, 11:11
  3. QAbstractItemModel for dummies
    By morty in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2006, 15:25
  4. Subclassing QAbstractItemModel
    By r366y in forum Qt Programming
    Replies: 2
    Last Post: 2nd May 2006, 08:46
  5. [QT4] QTreeView, QAbstractItemModel and sorting
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th March 2006, 20:16

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.