Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Is there a way to set the parent of a widget in QtDesigner?
Forum Updated to NodeBB v4.3 + New Features

Is there a way to set the parent of a widget in QtDesigner?

Scheduled Pinned Locked Moved Solved Qt for Python
6 Posts 3 Posters 1.1k Views
  • 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.
  • feiyuhuahuoF Offline
    feiyuhuahuoF Offline
    feiyuhuahuo
    wrote on last edited by
    #1

    I have a nested layout.
    4234ca17-90eb-4677-a3ed-14898a26525e-image.png
    I created this layout directly in QtDesigner. But I'm weird about the parents of these widgets. For example, the parent of label_ok_2_2 is group_box_ok. Why its parent is not its upper container horizontalLayout_18? Can we get the parent information directly in QtDesigner? Can we directly set the parent of a widget in QtDesigner? I want to do so because I want to do some dynamic settings according to the children of a QLayout.
    Any help is appreciated, thanks.

    eyllanescE 1 Reply Last reply
    0
    • feiyuhuahuoF feiyuhuahuo

      I have a nested layout.
      4234ca17-90eb-4677-a3ed-14898a26525e-image.png
      I created this layout directly in QtDesigner. But I'm weird about the parents of these widgets. For example, the parent of label_ok_2_2 is group_box_ok. Why its parent is not its upper container horizontalLayout_18? Can we get the parent information directly in QtDesigner? Can we directly set the parent of a widget in QtDesigner? I want to do so because I want to do some dynamic settings according to the children of a QLayout.
      Any help is appreciated, thanks.

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by eyllanesc
      #2

      @feiyuhuahuo The kinship relationship is between QWidget, that serves for memory management (for QObjects like QWidget) but it also serves for the process of creating the window or painting. There is no such relationship between layouts. The layouts are not visible elements but managers of the geometry. When a QWidget is established in a QLayout, it is established that it will be a child of the QWidget set to the layout.

      That has nothing to do with QtDesigner but with the design of Qt.

      horizontalLayout_18 is not a container, it is just a position and size handle.

      It seems that you have an XY problem since you have an objetive : I want to do so because I want to do some dynamic settings according to the children of a QLayout but you ask for a possible solution that no one guarantees will work.

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      1 Reply Last reply
      1
      • feiyuhuahuoF Offline
        feiyuhuahuoF Offline
        feiyuhuahuo
        wrote on last edited by
        #3

        @eyllanesc I can't understand clearly. What is an XY problem? Anyway, I found that if I create a dialog totally by QtDesigner and then put some widgets and layouts in it, regardless of the layouts, all the widgets' parents will be the dialog itself. But I can still set their parents manually with .setParent() function. I just found nowhere to set parent for a widget in QtDesigner.

        JonBJ eyllanescE 2 Replies Last reply
        0
        • feiyuhuahuoF feiyuhuahuo

          @eyllanesc I can't understand clearly. What is an XY problem? Anyway, I found that if I create a dialog totally by QtDesigner and then put some widgets and layouts in it, regardless of the layouts, all the widgets' parents will be the dialog itself. But I can still set their parents manually with .setParent() function. I just found nowhere to set parent for a widget in QtDesigner.

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #4

          @feiyuhuahuo said in Is there a way to set the parent of a widget in QtDesigner?:

          I just found nowhere to set parent for a widget in QtDesigner.

          You wouldn't want to, it doesn't make sense. In Designer its parent is whichever widget it has been placed onto.

          1 Reply Last reply
          1
          • feiyuhuahuoF feiyuhuahuo

            @eyllanesc I can't understand clearly. What is an XY problem? Anyway, I found that if I create a dialog totally by QtDesigner and then put some widgets and layouts in it, regardless of the layouts, all the widgets' parents will be the dialog itself. But I can still set their parents manually with .setParent() function. I just found nowhere to set parent for a widget in QtDesigner.

            eyllanescE Offline
            eyllanescE Offline
            eyllanesc
            wrote on last edited by
            #5

            @feiyuhuahuo Please read: https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem

            If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

            1 Reply Last reply
            0
            • feiyuhuahuoF Offline
              feiyuhuahuoF Offline
              feiyuhuahuo
              wrote on last edited by
              #6

              @eyllanesc @JonB Thanks, I think I need to be more familiar with QT.

              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