Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Redirect component to another container
Forum Updated to NodeBB v4.3 + New Features

Redirect component to another container

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 184 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.
  • P Offline
    P Offline
    PavloPonomarov
    wrote on last edited by
    #1

    Hello. I'm currently writing a retractable side panel. Example code:

    RowLayout{
    	property var parentElement: parent
            width: parentElement.width
            height: parentElement.height
            property var side: "left"
    	Button{
    		x: 0
                    y: 0
                    width: 20
                    height: parentElement.height
                    flat: true
                    text: (side === "left")?">":"<"
    		onClicked: { /*insert logic here*/);
    	}
            Pane{
                 id: content
            }
    }
    

    My problem is if I use this component as follows:

    SidePanel{
         Text{ text: "Some content" }
          Button { text: "Do stuff"; onClick: { /*do suff*/ }}
    }
    

    then components will be added to RowLayout.
    Is there a way to place content directly to the Pane?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Not sure but you might get this to work using default property:

      RowLayout {
        default property alias items: content.children
        Button {}
        Pane {
          id: content
        }
      }
      

      Sorry I can't test it at the moment, not sure if this code will work. There are also a few more ways to do it, but more "hacky".

      https://doc.qt.io/qt-5/qtqml-syntax-objectattributes.html#default-properties

      (Z(:^

      1 Reply Last reply
      1
      • P Offline
        P Offline
        PavloPonomarov
        wrote on last edited by
        #3

        This actually works! Thank you very much!

        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