Qt World Summit: Register Today!

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)

    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 ?

  • Lifetime Qt Champion

    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