[PyQt] QTreeView access violation

Dirk Wagener dwagen at stonethree.com
Thu Sep 13 09:53:49 BST 2007


I have the following problem when performing the following steps in 

* I have a QTreeView using a custom model.
* I expand a node that contains a bunch of items.
* I select one of the items (children) by clicking on it.
* I then edit the name of the item in-place (custom setData() 
* I signal a dataChanged() event.
* I send a signal from somewhere else that the parent must be refreshed.
* The parent removes all its children (removeRows()) and re-populates.
* CRASH!! (only sporadically)
   Qt gives my one of these:

"Qt has caught an exception thrown from an event handler. Throwing 
exceptions from an event handler is not supported in Qt.
You must reimplement QApplication::notify() and catch all exceptions 
there. "

A Visual Studio debugger Window pops up and it seems that an access 
violation took place!
Re-implementing notify() DOES NOT catch the access violation. How can I 
catch access violations
in PyQt?

I am not 100% sure about this, but it seems to have something to do with 
the fact that a selected item gets removed.
If I call clearSelection() before removing the rows, the violation does 
not happen! This feels like a bit of a hack. What is the
correct way to handle this?

Kind regards

Dirk Wagener <dwagen at stonethree.com>
(MSc. Electronic Engineering, Stell.)

Project Engineer
Stone Three Signal Processing (Pty.) Ltd.
+27 21 851 3123 (phone)
+27 21 851 3127 (fax)

We shall not cease from exploration and the end of all our exploring will
be to arrive where we started... and know the place for the first time.
T.S. Eliot

More information about the PyQt mailing list