Hey, I'm not clear on why you have to keep your own independent newList of all the QListWidgetItems. Why not just pull them from the list widget as you do for the old ones? Then you can be sure you aren't holding on to stale objects when you want to access the text values.
Justin On Tue, Jun 16, 2015 at 10:33 AM crazygamer <[email protected]> wrote: > Hi, > Am writing a renaming tool for maya. Its almost done but Im stuck on a > issue. > > I'm following Rob's book "Practical Maya Programming with Python". So I'm > keeping the Qt(PySide) code seperate from my maya code. > > Here's a quick laydown: > > #The window contains two list widgets (old names, new names) and two > buttons (load objects, rename objects). Old names list is not editable. > # The UI is made with Qt Designer and converted to python using pysideuic. > > # The way its supposed to work: > 1. Click "Load Objects" button to load selected objects(names) on both > list widgets. > 2. User edits the text on the "new names" list widget. > 3. Click the "Rename Objects" button to rename objects on the "old names" > widget with the naming from the "new names" widget. > > It works the first time. After that, I get this error: > > RuntimeError: Internal C++ object (PySide.QtGui.QListWidgetItem) already > deleted. > > > I create the QListWidgetItem in the loop as I want the "new names" list to > be editable. I can > understand qt/python clearing it as garbage collection. How can I create > the QListWidgetItem properly so it doesn't get cleared on refresh. > > Can someone help me understand and write this efficiently so I can keep > the list editable and > refresh/recreate the QListWidgetItem on each object load. What I've > written is quite crude. > > The ui file(converted to python) is attached with this post. > Here's the extracted code: (It also contains a test function so you can > test-run it with mayapy on a console) > http://pastebin.ubuntu.com/11722053/ > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/0d82af77-2068-4572-bef3-d20fecade05b%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/0d82af77-2068-4572-bef3-d20fecade05b%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1XKDQDoFYaLZJY0deHd%3DWWa_F_EM%2BGiOO-8M7UgfLq7A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
