QTreeView + QAbstractItemModel + QSortFilterProxyModel: inserting row crashes into Segmentation fault
-
Trying to combine "QTreeView + QAbstractItemModel + QSortFilterProxyModel".
When it is just "QTreeView + QAbstractItemModel" - everything works fine.
When I add QSortFilterProxyModel between view and source model - it starts to fail.
I mean there comes segmentation fault, and this is not stable - sometimes I get segmentation fault, sometimes row is inserted and everything is fine.Debugging shows, that the error appears long after insertRow execution is finished.
Here is a screenshot showing execution stack and crash point:"!http://i047.radikal.ru/1310/f9/2833f1f5d077t.jpg(Qt Segmentation fault)!":http://i047.radikal.ru/1310/f9/2833f1f5d077.jpg
And here is my minimal example project "TreeViewExample.zip":http://rapidshare.com/share/06FB98367B2C08268216D7EDDEF771EE
There is some excessiveness, like:
- TreeView is not enclosed into MainWindow directly, but into QDialogue (enclosed into MainWindow);
- initial data in tree are monstrously hardcoded (see ExObject constructor);
- order field calculation is left.
To see the error:
- open and build the project;
- run the project - you will see a text edit field and a tree;
- select some branch in a tree: for example x20;
- put cursor into test edit above, type in "x25" and press enter;
- it is supposed that branch x25 would be inserted after x20 (after selected).
If you have a branch inserted - repeat actions 2 or 3 times - the segmentation fault appears soon.
If it works fine on x20 - open x20 and insert a new branch after x201 (included in x20).
My current environment description
Qt Creator 2.8.1
Based on Qt 5.1.1 (MSVC 2010, 32bit)
Built at13:35:01, Aug 26 2013
Revision c3ed746c24
Qt 5.1.1 (don't know how to check revision)
MinGW 4.8
The same error was on Qt Creator 2.7.1 + Qt 5.1.0 + MinGW 4.8Is this my code fault (I missed some important thing in documentation)? Or some library feature?
Maybe someone can share some working example of "QTreeView + QAbstractItemModel + QSortFilterProxyModel" combination?