Publisher - Custom UI - Internal C++ object (PySide2.QtWidgets.QListWidgetItem) already deleted

Hello community,

So I’m extending the Publisher with some extra UI elements for some extra functionality. Bare with me, I’m not an expert in Qt.

Now, I’ve added a QListWidget which holds soms items. But I’m having some issues with the getter and setter.
So first I populate the list with a function that creates the items. Then I use the following code for the getting and setting. Obviously the setter code is not done yet. So mainly debugging and printing stuff there.

def worker_selection(self):
    checked_items = []
    for index in range(self.workers_list.count()):
        if self.workers_list.item(index).checkState() == QtCore.Qt.Checked:

    return checked_items

def worker_selection(self, value):
    for v in value:
        print v
        print v.isSelected()

Now when I select an item in the UI, go to another “layer” in the Shotgun view on the left and go back to the list again, I’m getting:

Internal C++ object (PySide2.QtWidgets.QListWidgetItem) already deleted.

So it looks like at the moment I want to do something with the Object in the setter, python deletes it.

Can anybody shine some light on this?



Hello, David. The “correct” way to setup custom widgets is to only interact with them using the predefined functions for create_*, get_*, and set_*. Here’s an example. Doing so will guarantee you only access the widgets when they are in scope, avoiding the issue you’re seeing.


1 Like

Cheers mate!

That pointed me in the right direction.
The answer was right in front of me the whole time.
I tried to work with the objects themselfs, but all I had to do was passing down a list to the setter.

I stared at my screen for too long I guess :wink: