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. QTreeView setFirstColumnSpanned() breaks expand/collapse

QTreeView setFirstColumnSpanned() breaks expand/collapse

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 3.2k Views 1 Watching
  • 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.
  • G Offline
    G Offline
    glevner
    wrote on last edited by
    #1

    In my QTreeView and QTreeModel, only the "leaves" of the tree use all the columns; items with children use only the first column. So, for those items, I call QTreeView::setFirstColumnSpanned(). Graphically, that does what I want. The problem is that mouse clicks on the arrows to the left of those items no longer expand/collapse the items. The mouse clicks are ignored. I can use the keyboard to expand/collapse (left arrow, right arrow, asterisk), but not the mouse.

    Anybody have any idea why this is happening, and how I might fix it?

    Another clue: if I call expandToDepth() in the constructor of my QTreeView subclass, mouse clicks work correctly on the items which are initially expanded, but not on lower levels of the tree.

    I am using Qt 5, and have the same problem on both Windows and Linux.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      glevner
      wrote on last edited by
      #2

      I have made some progress in figuring out what is happening. It depends on the width of the first column.

      Say a row spans all the columns, because setFirstColumnSpanned() has been called. If the row is a few levels down in the tree, it is offset to the right, so the arrow icon may be 50 or 100 pixels from the left margin. And if it is deep enough, or the first column is narrow enough, the arrow icon is offset beyond the right edge of the first column. When that happens, Qt will not allow the user to click on the arrow icon.

      That is, QTreeViewPrivate::itemDecorationAt() returns -1 in that case, because QHeaderView::logicalIndexAt() returns a non-zero column.

      Shouldn't QTreeViewPrivate::itemDecorationAt() take into account the spanning of an item?

      1 Reply Last reply
      0
      • G Offline
        G Offline
        glevner
        wrote on last edited by
        #3

        I have reported a bug for this: "QTBUG-31384":https://bugreports.qt-project.org/browse/QTBUG-31384

        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