[PySide] Problem with garbage collection

David Ching dc at dcsoft.com
Fri Feb 10 02:54:38 CET 2023


>from: "henry.wede at yahoo.com <mailto:henry.wede at yahoo.com> " <henry.wede at yahoo.com <mailto:henry.wede at yahoo.com> >

> 

>Thanks for looking that up.  It knew learning C++ would make me a better Python programmer :)

> Seems too hard though...

 

Sure, I learned Qt with C++ and only recently switched to Python for the dev productivity.  Glad my background is useful.  😊

 

>My method probably does seem strange, but I will try to explain it.

> I have to store a bunch of lists containing both commands and robot positions.

> I made different objects to store the items information because it keeps things organized.

> […]

> Then I thought that I would be clever... since I am making objects anyway, why not derive

> those objects from a QListWidgetItem?  Then when I need to display the objects I can just

> add them to a list widget and the displaying is done in only a couple lines of code.  Also, the

> program can change the icons or text color with just a couple lines.  But I only use one list

> widget to display the all of the lists - one at a time, of course.  The list widget is reused/recycled.

> 

>That is why I am putting things into a list widget, moving them around, storing them,

> clearing the list widget and doing it again.

> Probably not what the folks at Qt thought I was going to do.

 

Have you considered using a QListView instead of a QListWidget?  I believe that allows you to save your robot objects, etc. in a plain data object, and then display them in the same list display as QListWidget.  I do believe QListWidget is much easier, though and wonder if the model/view architecture is worth the increased complexity for your case.  But in any case, I think that is how the folks at Qt provided for what you are trying to do.

 

Thanks,

David

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20230209/70370a10/attachment-0001.htm>


More information about the PySide mailing list