Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Qml Vertical Tabbar

I would like to add Vertical TabBar to my app in a similar manner of what Qt Creater is doing in their app (as shown in picture). I have been searching how to simple make the TabBar vertical, yet did not find proper answers (thought its common to have it vertical).

Question: How could I make a Vertical Tab to navigate through the different qml files I have? If there are more suitable options, please suggest.

enter image description here

like image 728
Anas AG Avatar asked Mar 16 '26 21:03

Anas AG


1 Answers

A TabBar just uses a common ListView to display a bunch of TabButtons. You can customize it by overwriting the contentItem property and making the ListView vertical, like this:

// VertTabBar.qml
TabBar {
    id: control

    contentItem: ListView {
        model: control.contentModel
        currentIndex: control.currentIndex

        spacing: control.spacing
        orientation: ListView.Vertical   // <<-- VERTICAL
        boundsBehavior: Flickable.StopAtBounds
        flickableDirection: Flickable.AutoFlickIfNeeded
        snapMode: ListView.SnapToItem

        highlightMoveDuration: 0
        highlightRangeMode: ListView.ApplyRange
        preferredHighlightBegin: 40
        preferredHighlightEnd: height - 40
    }
}
like image 79
JarMan Avatar answered Mar 18 '26 16:03

JarMan