Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.12.2, 6.0.0
-
None
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
Gerrit Reviews
For Gerrit Dashboard: PYSIDE-1449 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
327385,2 | PySide6: Add QTestlib's QAbstractItemModelTester | 6.0 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
327423,2 | PySide6: Add QTestlib's QAbstractItemModelTester | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
327486,3 | PySide6: Add QTestlib's QAbstractItemModelTester | 5.15 | pyside/pyside-setup | Status: MERGED | +2 | 0 |