Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to arrange tabs of TabView in multiple rows?

From: http://doc.qt.io/qt-5/qml-qtquick-controls-tabview.html#details

TabView 
{
    Tab {
        title: "Red"
        Rectangle { color: "red" }
    }
    Tab {
        title: "Blue"
        Rectangle { color: "blue" }
    }
    Tab {
        title: "Green"
        Rectangle { color: "green" }
    }
}

These tabs get by default shown in a horizontal bar. How to display them in separate rows?

Like this:
Tab1
Tab2
Tab3

Rather than:
Tab1 Tab2 Tab3

like image 391
Aquarius_Girl Avatar asked Mar 18 '15 08:03

Aquarius_Girl


1 Answers

You need to hide standard tab bar, and create your own vertical bar.

Row {
    Column {
        Repeater {
            model: view.count
            Rectangle {
                width: 100
                height: 40
                border.width: 1
                Text {
                    anchors.centerIn: parent
                    text: view.getTab(index).title
                }
                MouseArea {
                    anchors.fill: parent
                    cursorShape: Qt.PointingHandCursor
                    onClicked: view.currentIndex = index
                }
            }
        }
    }
    TabView {
        id: view
        style: TabViewStyle {
            tab: Item {}
        }

        Tab {
            title: "Red"
            Rectangle { color: "red" }
        }
        Tab {
            title: "Blue"
            Rectangle { color: "blue" }
        }
        Tab {
            title: "Green"
            Rectangle { color: "green" }
        }
    }
}
like image 197
Meefte Avatar answered Oct 11 '22 02:10

Meefte