Results 1 to 5 of 5

Thread: Checkbox in QTreeView

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Checkbox in QTreeView

    IMHO the 2nd way, without editor in delegate is the way You should go.

    This will work like this
    QTreeView part:
    -> user click on index in QTreeView, change model data (signal click(QModelIndex)) - toggle currently stored value from 0 to 1 and from 1 to 0

    QAbstractItemDelegate part:
    -> paint() paint's checkbox and use that int value to determine what state it should has. setEditorData() (<- You don't need this one when You don't createEditor()) taht way code is simpler for this purpouse IMHO

    Model part:
    -> setData(), data()

    I don't want write here code for You, but what can help You are examples, especially:
    model = qtdir/examples/itemviews/editabletreemodel
    delegate = qtdir/examples/itemviews/coloreditorfactory (use checkBox, example uses combobox)
    Last edited by Talei; 9th July 2011 at 00:00. Reason: updated contents
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

Similar Threads

  1. Replies: 3
    Last Post: 1st April 2011, 04:58
  2. Replies: 0
    Last Post: 5th July 2010, 09:05
  3. QTreeView, checkbox problem
    By jwieland in forum Qt Programming
    Replies: 3
    Last Post: 23rd April 2009, 14:09
  4. How to set StyleSheet for checkbox in QTreeView;
    By visor_ua in forum Qt Programming
    Replies: 3
    Last Post: 7th April 2009, 11:46
  5. QTreeView: How to center a checkbox in a cell
    By chezifresh in forum Qt Programming
    Replies: 3
    Last Post: 19th December 2008, 12:11

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.