Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can not reorder QObject children
Forum Updated to NodeBB v4.3 + New Features

Can not reorder QObject children

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 947 Views 2 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.
  • Peter HarveyP Offline
    Peter HarveyP Offline
    Peter Harvey
    wrote on last edited by
    #1

    Hi, I am deriving in-app data from QObject so I can take advantage stuff like RTTI, parent/child relationship, etc. But I need to have non-const access to a QObjects child list - primarily to change the position of a child object in the list (similar to what QWidget does). Any thoughts on how I can do this?

    1 Reply Last reply
    0
    • jiancaiyangJ Offline
      jiancaiyangJ Offline
      jiancaiyang
      wrote on last edited by
      #2

      To reorder children, you can:

      1. Get all children list;
      2. Set parent to null one by one;
      3. Reorder them;
      4. Set parent to original parent one by one.

      我们自己的论坛:http://qtdream.com
      擅长三维角色仿真动画。

      Peter HarveyP 1 Reply Last reply
      3
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        Out of curiosity, why do you need to fiddle with the order of the children of a QObject object ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        Peter HarveyP 1 Reply Last reply
        3
        • SGaistS SGaist

          Hi and welcome to devnet,

          Out of curiosity, why do you need to fiddle with the order of the children of a QObject object ?

          Peter HarveyP Offline
          Peter HarveyP Offline
          Peter Harvey
          wrote on last edited by
          #4

          @SGaist basically for the same reason as QWidget - to maintain a Z-Order.

          1 Reply Last reply
          0
          • jiancaiyangJ jiancaiyang

            To reorder children, you can:

            1. Get all children list;
            2. Set parent to null one by one;
            3. Reorder them;
            4. Set parent to original parent one by one.
            Peter HarveyP Offline
            Peter HarveyP Offline
            Peter Harvey
            wrote on last edited by
            #5

            @jiancaiyang interesting - this may work :)

            1 Reply Last reply
            2

            • Login

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