如何在多行中安排TabView的选项卡?

Aqu*_*irl 5 qt qml qt5 qtquick2 qtquickcontrols

来自: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" }
    }
}
Run Code Online (Sandbox Code Playgroud)

默认情况下,这些选项卡显示在水平栏中.如何在单独的行中显示它们?

像这样:
Tab1
Tab2
Tab3

而不是:
Tab1 Tab2 Tab3

Mee*_*fte 5

您需要隐藏标准选项卡栏,并创建自己的垂直栏.

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" }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)