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. "expandBelow" in TreeView: Shortcut vs. method
Forum Updated to NodeBB v4.3 + New Features

"expandBelow" in TreeView: Shortcut vs. method

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 5.3k 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.
  • K Offline
    K Offline
    Knacktus
    wrote on last edited by
    #1

    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

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

      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.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Knacktus
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

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

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • K Offline
            K Offline
            Knacktus
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              Knacktus
              wrote on last edited by
              #6

              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. ;-)

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #8

                  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.

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #9

                    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.

                    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