"expandBelow" in TreeView: Shortcut vs. method



  • Hi guys,

    using PyQt I've got a major performance issue with my hand-coded "expandBelow" method of a QTreeView, which is supposed to expand the tree recursively below a selected row. However, there's a key shortcut for this action (at least on Windows): the "*" key. Despite not being as fast as the expandAll method (which is incredibly fast) it's considerably faster then my Python method.

    Any ideas, how the behaviour of the "*" key is implemented and how I could access it from PyQt?

    Cheers,

    Jan



  • In general, a treeview has a method for that:

    "QTreeView::expand":http://doc.qt.nokia.com/4.7/qtreeview.html#expand

    You could try it.



  • But it expands only one level. In my code I call this method for all children recursively. And that takes quite a long time. Here's the Python code I'm using:

    @
    def expand_below_recursive(self):
    index = self.selectedIndexes()[0]
    q = deque([index])
    while q:
    idx = q.popleft()
    self.expand(idx)
    for i in range(self.model.rowCount(idx)):
    q.append(self.model.index(i,0, idx))
    @

    By the way, browsing the source I've found a merge request for methods "expandBranch" and "collapsBranch". They don't seem to have made it to Qt 4.8, do they?



  • I have no idea. Where did you find the merge request? In gitorious or qtproject?



  • Here: http://qt.gitorious.org/qt/qt/merge_requests/2453

    As I'm not used to git I'm not sure what it all means. Status is "update", but the last reply in the thread is over a year old. Looks like it hasn't been pursued.



  • Ok, "Lab Rat" mistake:

    I had the expanded-signal connected to the resizeColumn-slot. The resizeColumn method is called on every expansion which is the culprit for the bad performance. As the expandAll method and probably the "*"-triggered expansion don't trigger the expanded-signal, the resizeColumn-method is not called in these cases.

    Now the Python method listed above is lightening fast. Hurray for Python ... and Qt, of course. ;-)



  • Interesting (and, frankly, a bit dissapointing) to see merge requests like these just rotting in gitorious...



  • I don'T know why, but in last time, gitorious seems not to be used anymore, as qtproject.org is used. For Qt, gitoripus is now a read only copy.
    I think, re pushing this request on qtproject would give it a bigger chance.



  • Yes, but that site has been open now for just over week, while the MR was in gitorious for well over a year now. I certainly hope the MR will be pushed to the new system, but I fear that not seeing your MR being taken up for more than a year can be such a demotivating experience that contributers won't bother anymore.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.