I am using the pyside QTreeWidget to create a basic ui to list which materials and or SG that has a specific V-Ray material ID assigned to it. The widget lists parent items with the shader ID as label and the child items are the materials or SG that have that ID assigned.
I have assigned the name of the material to the data attr so that when the item is clicked the material gets selected in the hypershade. As it works now if I were to rename the material it would no longer work since the widget is pointing to the name and not to the actual object.
I am sort of stuck here, my initial idea was to serialize a dict that was pointing to the pyNode, but the JSON.dumps method is giving me errors that my dict is not JSON serializable.
I am pretty new to pyside and especially the qtreewidget so any tips, ideas or pointers are very welcome!
Thanks, Johan
Why does the object need to be serialized to json? Can't you just store your object as data directly?
Also, you could subclass QTreeWidgetItem and store a custom item in the tree.
--
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 python_inside_m...@googlegroups.com.
To post to this group, send email to python_in...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
As you pointed out the best way is obviously to store the object as a custom data type in the threewidgetitem. I am quite new to pyside and found the documentation (http://srinikom.github.io/pyside-docs/) on the subject a bit hard to grasp. Do you have any good tips on how to do this or can you point me to some information on the subject?
Best regards,
Johan
# Now fetch it back out again by row, column
item = tree.itemAt(0, col)
print item.data(0, OBJECT_ROLE)
# <__main__.MyCustomType at 0x103f1d090>
( being quite new to this group should I delete the previous post when I post a reply ? )