Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Subclassing overriding 'parent' and retrieving it in instantiation
Forum Updated to NodeBB v4.3 + New Features

Subclassing overriding 'parent' and retrieving it in instantiation

Scheduled Pinned Locked Moved Solved Language Bindings
python
3 Posts 2 Posters 920 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • GofferG Offline
    GofferG Offline
    Goffer
    wrote on last edited by A Former User
    #1

    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 ?

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      What happens if you just do print self.parent?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      GofferG 1 Reply Last reply
      0
      • jsulmJ jsulm

        What happens if you just do print self.parent?

        GofferG Offline
        GofferG Offline
        Goffer
        wrote on last edited by
        #3

        @jsulm

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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved