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. QTreeView + QAbstractItemModel + QSortFilterProxyModel: inserting row crashes into Segmentation fault
Forum Updated to NodeBB v4.3 + New Features

QTreeView + QAbstractItemModel + QSortFilterProxyModel: inserting row crashes into Segmentation fault

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.5k 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
    Kanareyka
    wrote on last edited by
    #1

    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.8

    Is 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?

    Tenderly in love with QT, but it still says nay to me...

    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