Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1449

SelectionModel issue

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12.2, 6.0.0
    • PySide
    • None
    • Windows

    Description

      Hello,

      I think I found an issue with the selection model of the treeview.
      My goal is to provide users a tree that is already expanded and set to a specific item.
      But there is a crash when collapsing the tree once the item has been selected.
      If the selection part is commented, there is no crash

      I provided a small as possible example and a procedure to reproduce.
      The procedure is also in the script.
      If you need any explanation or if I made a design mistakem please let me know.

      EXPLANATION PART :

      1- Defines an abstract tree qmodel based on a Node class
      2- Defines a ElementQTreeModel bases on an Element class
      3- Defines a MyQModel bases on an MyElement class

      Now the user can add subelements and the indexes will be automtically created
      assuming the ElementQTreeModel calls `add_elements` from QTreeModel.

      A - Define an alphabet ['a', 'b', 'c', 'd']
      B - Set root elements to be each letter
      C - When an elements is expanded, add each letter as subelements using `fetchMore`

      This works and can be tested using `python abstract_tree.py`

      PROBLEM PART:

      For conveniance, we add a `set_selection_and_expand_to` to the tree.
      If a string param is given (as `ababc`) the tree will expand until element data
      matches.
      If at any moment a string part cannot be found, the expand process stops.
      If it is found it will select the matching element
      This process is done using the `rowsInserted` signal.

      This works and can be tested using `python abstract_tree.py abdc`

      It works. BUT, when enabling the last item selection :
          - the next 2 root elements after the first one expanded are not displayed.
          Yet, if you expand an item at the last level or one or two upper, they
          are now shown
          - if the first thing you do is collapsing an item 3 level or higher than
          the last one expanded, Qt crashes

      If you comment selection line #439, there is no issue

      LEADS :
          - there seems to be an issue with the selection model. When using right
          and left arrow keys after an expansion the collapsed items are not the
          selected one.
          - Search for keyword BUG in the code for problems variations

      Thank you !

      Attachments

        1. pyside1449.py
          15 kB
        2. pyside1449_qt6_startup_crash_stack.txt
          31 kB
        3. pyside1449_qt5_startup_crash_stack.txt
          29 kB
        4. pyside1449_qt5_collapse_crash_stack.txt
          41 kB
        5. no_bug.PNG
          no_bug.PNG
          5 kB
        6. bug.PNG
          bug.PNG
          5 kB
        7. abstract_tree.py
          14 kB
        For Gerrit Dashboard: PYSIDE-1449
        # Subject Branch Project Status CR V

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            p.charmoille paul charmoille
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes