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. qsortfilterproxymodel expand parent items
QtWS25 Last Chance

qsortfilterproxymodel expand parent items

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 668 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.
  • alomA Offline
    alomA Offline
    alom
    wrote on last edited by
    #1

    Where is the best place to handle expanding a filtered child's parent using a qsortfilterproxymodel?

    I'm just using the filterAcceptsRow in my proxy model. So far I tried to emit a custom signal in my proxy and connect it with the views expand function. This sorta works, but once a filtered item is found and the reg expression changes i get a stack overflow of a endless loop between my signal and filterAcceptsRow.

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

      Hi,

      When are you emitting that signal ?
      Why are you trying to expand the node while filtering ?

      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
      1
      • alomA Offline
        alomA Offline
        alom
        wrote on last edited by
        #3

        Hi SGaist,

        I tried to emit it right before the return of a True bool in the filterAccetpsRow.

        Well that was my first question, where is the best place to expand the parent node on a filtered item? The hierarchy can be a few leafs deep, so I'd like the user to see the expanded tree to the found item.

        I'm pretty sure during the recursive loop of the filterAcceptsRow is the wrong place. I was hoping there might be a filteringFinished signal or something once the filters is done.

        1 Reply Last reply
        0
        • gde23G Offline
          gde23G Offline
          gde23
          wrote on last edited by
          #4

          filterAcceptRow() is definitely the wrong place since it is called for every row, and you only need to expand once.

          Do you have a function that enables/disables filtering? Then I would expand the tree there before enabling the filter.

          1 Reply Last reply
          1
          • alomA Offline
            alomA Offline
            alom
            wrote on last edited by alom
            #5

            yep, I definitely only would like to call this once.

            I think i found a compromise, I connected the editingFinished signal on the lineedit, so when the user filters it might show a parent, indicating that there is data found, but not expanded. This gives the the opportunity to write the full name or correct mistakes without any calls each text change. The down side is maybe the user doesn't know the names that might be similar and need to see all the options to complete the name filter.

            When the user presses enter, I can do one recursion to expand the proxy model on any rows left. I dont like having mystery gui logic like this, but I dont want to make a science project out of this... unless someone else has a better approach?

            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