Results 1 to 8 of 8

Thread: QTreeWidget->clear() causing crash after sort

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeWidget->clear() causing crash after sort

    Where exactly do you call clear()?

  2. #2
    Join Date
    Jun 2007
    Posts
    19
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget->clear() causing crash after sort

    Quote Originally Posted by wysota View Post
    Where exactly do you call clear()?
    In a refresh() function in the QDialog that contains the Tree. It's called when the app loads to initially populate the tree, and is then connected to a button to refresh the list at any time.

    Clearing the list and iterating through a plugin list seems the easiest way to refresh, rather than checking for additions or deletions.

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

    Default Re: QTreeWidget->clear() causing crash after sort

    When you clear the widget, all its items will become invalid, so if you store a pointer to one (or more) of them somewhere, you can't use it anymore - you have to ask the widget for the item again. Because you never know what caused a slot to trigger, you should always check for validity of pointers you get as slot parameters.

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
  •  
Qt is a trademark of The Qt Company.