Results 1 to 3 of 3

Thread: problem with custom QAbstractItemModel derived class when changing data

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default problem with custom QAbstractItemModel derived class when changing data

    Hi!

    I have a problem with my class derived from QAbstractItemModel when I want to delete an item.

    I already tried signals layoutChanged() and beginRemoveRows()/endRemoveRows() and have no idea, what can be wrong.

    I attached a simple example of my problem.
    As you run it, please select the third row. After a few seconds I'm removing the second item and sometimes it causes segfault. The backtrace from GDB looks like this:

    Qt Code:
    1. (gdb) backtrace
    2. #0 0x0804e667 in AbstractModel::parent(QModelIndex const&) const ()
    3. #1 0x0086660c in ?? () from /usr/lib/libQtGui.so.4
    4. #2 0x00866dcb in ?? () from /usr/lib/libQtGui.so.4
    5. #3 0x00867111 in QItemSelectionModel::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib/libQtGui.so.4
    6. #4 0x00d17c9a in QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) () from /usr/lib/libQtCore.so.4
    7. #5 0x00d263d5 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/libQtCore.so.4
    8. #6 0x00d76d77 in QAbstractItemModel::layoutChanged() () from /usr/lib/libQtCore.so.4
    9. #7 0x0805529b in AbstractModel::qt_metacall(QMetaObject::Call, int, void**) ()
    10. #8 0x00d17c9a in QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) () from /usr/lib/libQtCore.so.4
    11. #9 0x00d263d5 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/libQtCore.so.4
    12. #10 0x08054ff9 in AbstractItem::updateModel() ()
    13. #11 0x0804d335 in AbstractItem::operator-=(AbstractItem*) ()
    14. #12 0x0804ddc8 in AbstractItem::update() ()
    15. #13 0x0805505d in AbstractItem::qt_metacall(QMetaObject::Call, int, void**) ()
    16. #14 0x00d17c9a in QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) () from /usr/lib/libQtCore.so.4
    17. #15 0x00d263d5 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/libQtCore.so.4
    18. #16 0x00d77aa7 in QTimer::timeout() () from /usr/lib/libQtCore.so.4
    To copy to clipboard, switch view to plain text mode 

    My question is: How can I safely delete data and inform the model (and treeview) about this change?
    Attached Files Attached Files
    Last edited by slodki; 12th May 2010 at 09:47.

Similar Threads

  1. Can not cast into the derived class from QScrollBar
    By learning_qt in forum Qt Programming
    Replies: 2
    Last Post: 19th December 2008, 10:23
  2. no frame on Qlabel derived class
    By tupu_83 in forum Qt Programming
    Replies: 2
    Last Post: 19th November 2008, 16:01
  3. Can't compile custom class derived from QGLWidget
    By stealth86 in forum Qt Programming
    Replies: 1
    Last Post: 5th July 2007, 17:55
  4. rtti() of derived class
    By quickNitin in forum Newbie
    Replies: 4
    Last Post: 8th October 2006, 14:20
  5. Signal/slot looking in base class, not derived class
    By georgie in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2006, 07:36

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.