Results 1 to 2 of 2

Thread: QTreeWidget, double-clicks and assertion errors

  1. #1
    Join Date
    Mar 2006
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default QTreeWidget, double-clicks and assertion errors

    Qt 4.1.4 commercial version on Windows XP

    I've attached a sample program that illustrates what is occurring.

    I have two QTreeWidgets and two push buttons (add and remove). The list on the left is the 'available' list. The list on the right is the 'selected' list. As long as I use the Add/Remove buttons everything is fine. When I double-click on an item in the 'selected' list, it will be removed without incident as long as I am not removing the last remaining item. If I attempt to double-click on the last item I get:

    ASSERT failure in QVector<T>::at "index out of range"
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeWidget, double-clicks and assertion errors

    This error is present in Linux 4.1 too. As a workaround, I am using a timer with 0 timeout, which is triggered after slot handlers return. In the timeout slot I simply delete the item.

    Qt Code:
    1. void Dialog::on_allTree_userDoubleClicked( const QString &user, int level,
    2. hackitemtodelete = user; // class member storing the item to delete
    3. QTimer::singleShot(0, this, SLOT(hackdeleteitem())); // single shot timer that triggers the delete
    4. }
    5.  
    6. void Dialog::hackdeleteitem( ) {
    7. allTree->removeUser(hackitemtodelete); // item gets deleted
    8. hackitemtodelete = ""; // "pointer" is cleared
    9. }
    To copy to clipboard, switch view to plain text mode 

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.