Results 1 to 3 of 3

Thread: Clearing a QTreeWidget in CustomContextMenuRequest causes crash

  1. #1
    Join Date
    Jul 2017
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Clearing a QTreeWidget in CustomContextMenuRequest causes crash

    Hi,

    I'm struggling to get the following work:
    Ive connected a CustomContextMenuRequest to a QWidgetTree and indeed the menu pops open. But, however, when I want to clear this QWidgetTree in this request I get a null pointer exception. When i run this piece of code in another place or slot it works just fine.

    When there are multiple items present in the treewidget, i can delete them one for one, and everything works fine, but when I delete the last one the exception occurs again.

    Qt Code:
    1. void N3LAB_Software::contextMenuTree(const QPoint& pos){
    2. this->objectList->clear(); % The QTreeWidget
    3. }
    To copy to clipboard, switch view to plain text mode 

    Does somebody know whats causing this problem or how to fix this?

    Thanks,

    Perry

    Ps:
    Im using Qt 5.6 with visual studio 2015

  2. #2
    Join Date
    Jun 2012
    Posts
    14
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Clearing a QTreeWidget in CustomContextMenuRequest causes crash

    The cause is probably that the context menu is still visible when the underlying model is cleared. You could try to delay the clearing of the widget by using a custom event (QApplication:ostEvent and then clear the widget when the event is processed).

  3. #3
    Join Date
    Jul 2017
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Clearing a QTreeWidget in CustomContextMenuRequest causes crash

    Already solved the problem,

    The cause was that there was a selectionchanged signal while there were no objects left.

    Thanks

Similar Threads

  1. QTreeWidget crash (improver use?)
    By csernai.csaba in forum Qt Programming
    Replies: 5
    Last Post: 24th March 2013, 22:17
  2. Replies: 8
    Last Post: 26th May 2011, 16:52
  3. Replies: 3
    Last Post: 9th May 2010, 16:17
  4. Having trouble clearing a QTreeWidget.
    By Nyphel in forum Qt Programming
    Replies: 28
    Last Post: 10th October 2007, 16:33
  5. Clearing a QComboBox causes a crash
    By tony@hitachi in forum Qt Programming
    Replies: 6
    Last Post: 8th March 2007, 16:37

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.