Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Get identical signal parameter values when selecting or deselecting an item in a QTreeView
Forum Update on Monday, May 27th 2025

Get identical signal parameter values when selecting or deselecting an item in a QTreeView

Scheduled Pinned Locked Moved Unsolved General and Desktop
selectionqtreeview
2 Posts 2 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Moschops
    wrote on last edited by Moschops
    #1

    I have a QTreeView. If I have a node, with one child, and both that node and its child are selected, I get the same parameters in the selectionChanged signal whether I am selecting OR deselecting the node.

    By which I mean, if I left-click on the node, the QItemSelection parameter in the selectionChanged signal containing the newly selected items is empty, and the selectionChanged signal containing the newly deselected items is not empty (which is NOT what I expected - I clicked one item, I expected the selected list to be that item and the deselected list to be the child).

    if I left-click on it with CTRL held down (which I would expect to be the deselection action), the parameters in the signal are identical. So it seems that it doesn't matter whether the user is left-clicking, or CTRL+left-clicking, the signal parameters are the same. Doesn't matter whther the user is left-clicking on something already selected, or CTRL-left-clicking on it, the signal is identical.

    The selection mode is extended selection. I was expecting the signal parameters to indicate that the item was selected if the action was just left-click, and deselected if the action was CTRL-left-click.

    But it isn't. Same, both ways, but ONLY if I have a node with a single child.

    If I have a node with many children, clicking on the node selects the node and deselects the children (as expected), CTRL-clicking on the node deselects the node and leaves all the children selected (as expected).

    Basically, the behaviour seems wrong ONLY when there is a node with a single child. Is this some kind of bug I've stumbled across? I am using 4.8.something

    ALTERNATIVELY, I'm massively missing the meaning of these parameters, in which case could someone explain them to me in simple terms. I know I've misunderstood them inthe past. I seem to have a real blind spot at this point in the QT documentation, having trouble understanding what they mean to represent with these parameters. Under the old, more useful documentation system, other people had added notes to the documentation to amplify the meaning, but sadly all that useful community-sourced was removed during the revamp.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you provide a minimal compilable example that shows that behavior ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved