Subclassing overriding 'parent' and retrieving it in instantiation



  • Hi community !

    this title is very confusing but i couldn't really figure out how to name this post.
    My problem is simple

    I have a subclass

    class TaskWidget(QtGui.QWidget):
        def __init__(self, taskName, parent=None):
            super(TaskWidget, self).__init__(parent)
    

    when sublclassing it :

    self.taskTemplate = TaskWidget(taskName, parent=aWidget)
    self.taskTemplateLayout.addWidget(self.taskTemplate)
    

    then in my class definition I would have thought that :

    print self # return the subclassed widget OK
    print self.parent() # should return aWidget ?
    

    but it raises an error : # TypeError: 'aWidget' object is not callable

    I m trying to go through the hierarchy so I can find a specific Widget.

    Is that the proper way of doing it ?


  • Moderators

    What happens if you just do print self.parent?



  • @jsulm

    I found out.
    stupid mistake, I was overiding self.parent = parent in my init() ...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.