[PyQt] Returning a subclass
David Klasinc
bigwhale at lubica.net
Thu Jul 10 10:13:23 BST 2008
Greetings,
here is the code:
class myAction (QtGui.QAction):
def __init__ (self, parent, myProperty):
QtGui.QAction.__init__ (self, parent)
self.myProperty = myProperty
Later this myAction is instanced and added to a toolbar
someAction = myAction (self, "The Property")
self.toolbar.addAction(myAction)
Then in the end I want to iterate through all the actions in toolbar:
for a in self.toolbar.actions():
print type(a)
print a.myProperty
toolbar.actions() returns a list of QActions, is there a way to recast
this QAction back to myAction? Is the information about subclass lost
during this process? First print in the above code will print
<class 'PyQt4.QtGui.QAction'>
And the second will raise the AttributeError obviously.
Any ideas on this one?
Regards,
David
More information about the PyQt
mailing list