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. How to properly group objects with stacklayout
Forum Update on Monday, May 27th 2025

How to properly group objects with stacklayout

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

    I'm trying to get a tab bar to switch position from a repeater to another item.

    Currently I have this:

    TabBar {
        id: bar
        width: parent.width
        TabButton {
            text: qsTr("History")
        }
        TabButton {
            text: qsTr("Details")
        }
    
    }
    StackLayout {
        id: stack
        width: parent.width
        currentIndex: bar.currentIndex
    
        Repeater {
            id: repeat
            model: attributes
    
            Row {
                id: detailsTab
                Layout.fillWidth: true
                clip: true
                spacing: 5 * scaleFactor
    
                Text {
                    Layout.preferredWidth: popupColumn.width * 0.55
                    Layout.fillHeight: true
                    text:  attributeName
                    wrapMode: Text.WrapAnywhere
                    font.pixelSize: 12 * scaleFactor
                    color: "#FFFCF7"
                }
    
                Text {
                    Layout.fillWidth: true
                    Layout.fillHeight: true
                    text:attributeValue
                    wrapMode: Text.WrapAnywhere
                    font.pixelSize: 12 * scaleFactor
                    color: "#FFFCF7"
    
                }
            }
        }
    
        Item {
            id: discoverTab
        }
    }
    

    When the tab button history is clicked i expect the entire repeater to be displayed. Instead what happens is one field from the text object is displayed and when I click details tab the next text from the repeater is displayed.

    How do I group properly to get the functionallity I want?

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Eeli K
      wrote on last edited by Eeli K
      #2

      Could you give self-contained working code? (Edit: which can be run and shows the problem)

      1 Reply Last reply
      1
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #3

        Just try your sample with two rectangles in a row. I tried and it is working fine. It could be issue with Layout what you have mentioned.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        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