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. Expander Control in QML

Expander Control in QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 3 Posters 4.4k 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.
  • JeniferJ Offline
    JeniferJ Offline
    Jenifer
    wrote on last edited by
    #1

    Hello, I want to build a expandable component with a header in QML, such that when i click on the header the component expands and on clicking it again it should collapse. All the components below the expandable component should move relative to the expandable component. This is somewhat similar to tree view but the component here is static a form content, so is there a better alternative available. Since i am new to Qt Quick i am not completely aware of the components and controls available. Any help would be greatly appreciated
    Thank You

    raven-worxR 1 Reply Last reply
    0
    • JeniferJ Jenifer

      Hello, I want to build a expandable component with a header in QML, such that when i click on the header the component expands and on clicking it again it should collapse. All the components below the expandable component should move relative to the expandable component. This is somewhat similar to tree view but the component here is static a form content, so is there a better alternative available. Since i am new to Qt Quick i am not completely aware of the components and controls available. Any help would be greatly appreciated
      Thank You

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Jenifer
      something like this?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      JeniferJ 1 Reply Last reply
      0
      • raven-worxR raven-worx

        @Jenifer
        something like this?

        JeniferJ Offline
        JeniferJ Offline
        Jenifer
        wrote on last edited by
        #3

        @raven-worx

        Ya exactly, i have gone through this blog, its quite informative. Using relative positioning, like anchoring i am able to achieve this. But i wanted to know is there any better way or built in controls available to achieve something similar to this.

        raven-worxR 1 Reply Last reply
        0
        • JeniferJ Jenifer

          @raven-worx

          Ya exactly, i have gone through this blog, its quite informative. Using relative positioning, like anchoring i am able to achieve this. But i wanted to know is there any better way or built in controls available to achieve something similar to this.

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @Jenifer said:

          But i wanted to know is there any better way or built in controls available to achieve something similar to this.

          Then you need to clarify what you want and why you don not like this solution...

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          JeniferJ 1 Reply Last reply
          0
          • raven-worxR raven-worx

            @Jenifer said:

            But i wanted to know is there any better way or built in controls available to achieve something similar to this.

            Then you need to clarify what you want and why you don not like this solution...

            JeniferJ Offline
            JeniferJ Offline
            Jenifer
            wrote on last edited by
            #5

            @raven-worx
            If there are built in controls to do it that would be helpful as the expandable component is bit complex and the I need the cascading effect. If the component is expanded all the components below it should move down and when the component is collapsed the components below it should move up. So I would like to know if there is a better way or this is the better possible option

            Julien BJ 1 Reply Last reply
            0
            • JeniferJ Jenifer

              @raven-worx
              If there are built in controls to do it that would be helpful as the expandable component is bit complex and the I need the cascading effect. If the component is expanded all the components below it should move down and when the component is collapsed the components below it should move up. So I would like to know if there is a better way or this is the better possible option

              Julien BJ Offline
              Julien BJ Offline
              Julien B
              wrote on last edited by Julien B
              #6

              Hello @Jenifer ,

              Have you tried to anchor the top of the below component to the bottom of the one above?

              The exemple below makes the blue rectangle collapse an expand when you click on the red one and the red one follows.

              Is that the kind of behaviour you want?

              Rectangle {
                  id: rect1
                  width: 64; height: 64
                  y: 64
                  x: 64
                  color: "blue"
                  
                  Behavior on height { NumberAnimation { duration: 250 } }
              }
              Rectangle {
                  id: rect2
                  width: 64; height: 64
                  anchors.top: rect1.bottom
                  anchors.left: rect1.left
                  color: "red"
              
                  MouseArea {
                      anchors.fill: parent
                      onClicked:
                          if (rect1.height === 0)
                              rect1.height = 64
                          else
                              rect1.height = 0
                  }
              }
              
              
              1 Reply Last reply
              0
              • JeniferJ Offline
                JeniferJ Offline
                Jenifer
                wrote on last edited by
                #7

                Thank you all , I did it as mentioned by @Julien-B anchoring the top of the below component to the bottom of the one above and it worked great

                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