Orange Forum • View topic - [solved] RuntimeError: underlying C/C++ object has been del

[solved] RuntimeError: underlying C/C++ object has been del

A place to ask questions about methods in Orange and how they are used and other general support.

[solved] RuntimeError: underlying C/C++ object has been del

Postby whoeverest » Thu May 31, 2012 16:44

Hey guys, I have a problem with Qt, so perhaps someone of you can help me.

I'm trying to implement a thumbnail view that will display images in every one of the widgets. After a couple of dead ends, I ended up using QListView for which I have to write a custom model (the alternative was QListWidget that has addItem()-like functions implemented.)

Now, the idea is the subclass QAbstractListModel and override data() and rowCount() functions. I did this, made a class ThumbnailsListModel(QAbstractListModel) and tried to set the view a model with the thumbnails.setModel(my_thumbnail_model). This is where an error happens and I have no idea how to deal with it:

Code: Select all
Traceback (most recent call last):
  File "/home/whoeverest/code/orange/Orange/OrangeWidgets/Test/OWGenericWidget.py", line 62, in <module>
    ow = OWGenericWidget()
  File "/home/whoeverest/code/orange/Orange/OrangeWidgets/Test/OWGenericWidget.py", line 48, in __init__
    thumbnails.setModel(model)
RuntimeError: underlying C/C++ object has been deleted


Here is a link to the source code: http://pastebin.com/Dbzd9Yeu

So, if anyone has any ideas or maybe had to deal with this Qt issue, please share. Thanks.
Last edited by whoeverest on Thu May 31, 2012 17:59, edited 1 time in total.

Re: RuntimeError: underlying C/C++ object has been deleted

Postby Ales » Thu May 31, 2012 16:59

You have to call the QAbstractListModel.__init__ in the ThumbnailsListModel subclass.
Code: Select all
class ThumbnailsListModel(QAbstractListModel):
    """A model for the thumbnail view."""
    def __init__(self):
        QAbstractListModel.__init__(self)
        self.strings = ['and','rej','neshto','drugo']

Re: RuntimeError: underlying C/C++ object has been deleted

Postby whoeverest » Thu May 31, 2012 17:59

Ooooooh, right. Thanks Ales!


Return to Questions & Support