gpt4 book ai didi

qt - 修复 QML 中的水平滚动

转载 作者:行者123 更新时间:2023-12-03 14:10:01 24 4
gpt4 key购买 nike

我想用于 Scroll Bar Example .

我尝试将此示例用于个人应用。我的 main.qml 文件是这样的:

     Flickable {
id: view
anchors.fill: parent
contentWidth: bobol.width
contentHeight: bobol.height
Column {
id : bobol
Rectangle {
width: 400
height: 100
color: 'red'
MouseArea {
id: sideButtonMouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
parent.color = '#4872E8'
}}}
Rectangle {
width: 200
height: 1000
}
}
states: State {
name: "ShowBars"
when: view.movingVertically
PropertyChanges { target: verticalScrollBar; opacity: 1 }}
transitions: Transition {
NumberAnimation { properties: "opacity"; duration: 400 }}}
ScrollBar {
id: verticalScrollBar
width: 12; height: view.height-12
anchors.right: view.right
opacity: 10
orientation: Qt.Vertical
position: view.visibleArea.yPosition
pageSize: view.visibleArea.heightRatio}

我想修复这个例子中的水平滚动?我该如何解决这个问题?

最佳答案

你在找这样的东西吗:

import QtQuick 1.0
Item{
Flickable {
id: view
anchors.fill: parent
contentWidth: bobol.width
contentHeight: bobol.height
Row {
id : bobol
Rectangle {
width: 100
height: 400
color: 'red'
MouseArea {
id: sideButtonMouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
parent.color = '#4872E8'
}}}
Rectangle {
width: 1000
height: 200
}
}
states: State {
name: "ShowBars"
when: view.movingHorizontally
PropertyChanges { target: verticalScrollBar; opacity: 1 }
}
transitions: Transition {
NumberAnimation { properties: "opacity"; duration: 400 }
}
}
ScrollBar {
id: verticalScrollBar
width: view.width-12; height: 12
anchors.bottom: view.bottom
opacity: 10
orientation: Qt.Horizontal
position: view.visibleArea.xPosition
pageSize: view.visibleArea.widthRatio
}
}

关于qt - 修复 QML 中的水平滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15244527/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com