Skip to content

Instantly share code, notes, and snippets.

@xiaoqiangwang
Last active December 3, 2021 07:42
Show Gist options
  • Save xiaoqiangwang/388be0d396c2779f59ad8fa4dc54d66b to your computer and use it in GitHub Desktop.
Save xiaoqiangwang/388be0d396c2779f59ad8fa4dc54d66b to your computer and use it in GitHub Desktop.
QtQuick ListView used as a sidebar
import QtQuick 2.7
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
import QtQuick.Templates 2.12 as T
Rectangle {
border.color: 'black'
width: 500
height: 400
anchors.centerIn: parent
property int tabPosition: 2
ListView {
id: listview
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
width: 50
clip: true
model: 10
orientation: ListView.Vertical
spacing: 2
delegate: TabButton {
//border.width: 2
implicitHeight: label.implicitWidth
implicitWidth: label.implicitHeight
contentItem: Label {
id: label
text: 'Item: ' + index
font.pixelSize: 15
transform: [
Rotation {
angle: tabPosition == 2 ? -90 : 90
},
Translate {
x: tabPosition == 2 ? -padding : label.implicitHeight - padding
y: tabPosition == 2 ? label.implicitWidth - padding: -padding
}
]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment