Results 1 to 2 of 2

Thread: How to create QStandardItem with two checkboxes in QTreeView

  1. #1
    Join Date
    Oct 2009
    Posts
    16
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default How to create QStandardItem with two checkboxes in QTreeView

    Hi gus,

    I still do not believe that I could not find the answer for the question in the forum history... I though it was quite normal case...


    So the question actually is how can I create QTreeView where every node has two check boxes (it does not have to be QStandardItem based, but prefferable as I'm already using it in my program).

    I could add one more column into the QTreeView and put the second check box in there but in this case the second check box will be visually located in a different column (aligned by that column). I want the second check box to be displayed right next to the first one (indented in the same way as the first check box)

    Thank you very much for your help in advance !

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to create QStandardItem with two checkboxes in QTreeView

    I would implement custom delegate where I would draw checkboxes with QStyle or QStylePainter and implement clicking on it in QAbstractItemDelegate::editorEvent(). I would not implement highlight on mouse hover, because it will be more complicated and is not necessary. Of course check state of those checkboxes would be stored in model, not necessarily in Qt::CheckStateRole only as there are 2 checkboxes. And then I would use this delegate only in this one column where it is needed so I wouldn't have to take care about other columns in delegate while implementing it.
    That's my idea :]

  3. The following user says thank you to faldzip for this useful post:

    topoden (19th April 2010)

Similar Threads

  1. QTreeView and CheckBoxes
    By FreeG in forum Qt Programming
    Replies: 2
    Last Post: 9th December 2009, 09:36
  2. Question on checkable QStandardItem in QTreeView
    By ttvo in forum Qt Programming
    Replies: 1
    Last Post: 3rd April 2009, 00:30
  3. qtreeview + checkboxes
    By lamera in forum Newbie
    Replies: 9
    Last Post: 6th September 2008, 22:10
  4. Replies: 3
    Last Post: 25th July 2008, 14:30
  5. QTreeView with checkboxes
    By shad in forum Qt Programming
    Replies: 1
    Last Post: 4th May 2006, 13: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.