Results 1 to 2 of 2

Thread: QTreeView parent/child selection behaviors (ghost highlighting)

  1. #1
    Join Date
    Dec 2011
    Posts
    60
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTreeView parent/child selection behaviors (ghost highlighting)

    I have a QTreeView with parents/children and want to do the following:

    1. Only allow the parent of an item to be selected
    2. Have the children be unselectable, but allow their checkboxes to be toggled

    However -- clicking on a child item does the following two (bad) things:

    1. It removes the selection from the parent
    2. It leaves some "highlight" mark behind on the child.

    Note that I've made the children "unselectable" via model flags, but the two issues above still occur. How can I prevent both of these things from happening?
    ----------

    DESIRED BEHAVIOR

    If the user clicks on a child, I want to keep the selection on the Parent uninterrupted (without manually flipping it back to the parent, which causes a "flicker"). And, I don't want the child to get "highlighted" by the translucent selection thing.

    Pictures to illustrate:

    Normal state. Parent is selected. Children have checkboxes.
    treeview1.PNG

    Bad behavior. Clicking on 2nd child (that's flagged as unselectable) causes the Parent to lose its selection, and gives the child the ghost selection
    treeview2.PNG

    Desired. This is what I want to see when I click on a child item -- the checkbox toggles, and the Parent remains selected without interruption.
    treeview3.PNG

    This must be possible, but I can't find the right combination of settings to get the selections to work as in the 3rd picture.

    Any help would be greatly appreciated.
    Last edited by alketi; 1st April 2015 at 22:48.

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: QTreeView parent/child selection behaviors (ghost highlighting)

    If you are using a custom model, please post your code. If you are using QStandardItemModel have you looked at QStandardItem::setFlags?

Similar Threads

  1. Replies: 2
    Last Post: 25th February 2015, 19:18
  2. styling parent but not child?
    By ugluk in forum Qt Programming
    Replies: 3
    Last Post: 13th October 2011, 03:55
  3. Parent child relationship in Qt
    By TheIndependentAquarius in forum Newbie
    Replies: 18
    Last Post: 14th July 2011, 09:43
  4. Parent Child for window
    By febil in forum Qt Programming
    Replies: 6
    Last Post: 1st April 2009, 06:00
  5. QTreeView PARENT & CHILD
    By zeeb100 in forum Qt Programming
    Replies: 1
    Last Post: 10th February 2009, 15:53

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.