Nominate our 2022 Qt Champions!

QTreeWidget with Tristate

  • I need to implement a QTreeWidget with group nodes and leaf nodes. I want only the group nodes to be in tristate mode. I set the group nodes to tristate mode using setflags(..) which is not done for the leaf nodes. When I run the code, clicking the checkbox cycles through all three states not just check and unchecked as desired. I've also tried setting Qt::ItemNeverHasChildren for the leaf nodes but it has no effect. What have I missed? Thanks for the help.

  • Moderators

    Hi, welcome to devnet.

    Flags are propagated to the children so you can either set all wanted flags on the child explicitly to overwrite whatever came from the parent, or unset just the tri-state flag on the child.

  • That worked. I knew it had to be something simple. Thanks.

Log in to reply