Results 1 to 3 of 3

Thread: Buttons to add new children/siblings on QTreeView entries

  1. #1

    Default Buttons to add new children/siblings on QTreeView entries

    Hi,

    I want to build a QTreeView that displays a number of buttons on each row (such as "delete current row", "add sibling below this row", "add child below this row").
    The three possibilities for this (that I see) are
    - setIndexWiget() connected to a slot which uses the selection in the treeview to figure out where to insert/delete something
    - a custom delegate - Is there a way for a delegate to figure out on which item it was activated (i.e. get the corresponding modelindex)?
    - and of course to implement a custom view which seems like the most work.

    My Questions are:
    - Is there any important reason to pick one over the other (e.g. setIndexWiget() might not scale well for large numbers of tree items I assume. On the other hand delegates (as I currently understand them) may not actually be intended to be used to modify the model in such a way but rather only to modify data of model items)?
    - Are there other options of doing this that may be better for some reason?
    - And taking one step back: When implementing a list[-of-lists]* with such buttons on each list entry, is a QTreeView the right way to go in the first place?

    Best,
    xdn
    Last edited by xadian; 3rd September 2014 at 14:32.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Buttons to add new children/siblings on QTreeView entries

    A delegate knows which index it is currently displaying/editing.

    If you data is, as you said, list of list, you could consier QColumnView, maybe with the buttons outside or on the preview widget.

    Cheers,
    _

  3. #3

    Default Re: Buttons to add new children/siblings on QTreeView entries

    Good to know. In that case I would currently lean towards the custom delegate solution.
    A QColumnView with a split view for hierarchies is not what I want. All lists should be displayed as in a single view with slight indentations. And buttons for these functions outside of the main widget is precisely what I want to avoid.

    Note: I miswrote earlier, what I'm trying to visualize is actually a list[-of-lists]* .
    Last edited by xadian; 3rd September 2014 at 14:37.

Similar Threads

  1. Replies: 1
    Last Post: 27th July 2013, 00:35
  2. How to set widgets as children items on QTreeView
    By q130s in forum Qt Programming
    Replies: 3
    Last Post: 9th March 2013, 23:40
  3. QTreeView children with multiple coulms
    By maxpower in forum Qt Programming
    Replies: 2
    Last Post: 20th June 2012, 14:10
  4. QTreeView adding children to the view
    By Tux-Slack in forum Qt Programming
    Replies: 2
    Last Post: 20th October 2007, 09:28
  5. QTreeView and QStandardModel : add children
    By Valheru in forum Newbie
    Replies: 7
    Last Post: 19th September 2006, 17:24

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.