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. TabBar/StackLayout inside Column

TabBar/StackLayout inside Column

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
tabbuttonstacklayoutcontrols 2column
1 Posts 1 Posters 592 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.
  • M Offline
    M Offline
    Mixlu
    wrote on 17 Aug 2020, 11:13 last edited by
    #1

    Hi,

    I would like to implement TabBar with StackLayout in order to switch between different views. I also would like that the selected view render inside a Column.

    But my problem is that the selected view is not correctly displayed inside the column (the view is rendered at the top), see screenshot bellow.

    Here is my simple implementation (I would like the view to appear between the TabBar and the buttons):

    import QtQuick 2.14
    
    import QtQuick.Controls 2.14
    import QtQuick.Layouts 1.14
    
    ApplicationWindow {
        id: main
        width: 400
        height: 400
        color: "#000000"
        visible : true
    
        Column {
            spacing: 10
    
            Text {
                x: 80
                text: "Text"
                color: "#FFFFFF"
            }
    
            TabBar {
                id: bar
                width: parent.width
                TabButton {
                    text: qsTr("Home")
                }
                TabButton {
                    text: qsTr("Discover")
                }
                TabButton {
                    text: qsTr("Activity")
                }
            }
    
            StackLayout {
                width: parent.width
                currentIndex: bar.currentIndex
                Item {
                    Text {
                        text: qsTr("homeTab")
                        color: "#FFFFFF"
                    }
                }
                Item {
                    Text {
                        text: qsTr("discoverTab")
                        color: "#FFFFFF"
                    }
                }
                Item {
                    Text {
                        text: qsTr("activityTab")
                        color: "#FFFFFF"
                    }
                }
            }
    
            RowLayout {
                Button {
                    text: "Button 1"
                }
    
                Button {
                    text: "Button 2"
                }
            }
        }
    }
    

    Here is a screen of my problem :
    2cc5f8e8-7f50-4ec5-9994-4214fc6fe5a1-image.png

    1 Reply Last reply
    0

    1/1

    17 Aug 2020, 11:13

    • Login

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