importar QtQuick 2.0 importar
QtQuick.Controls 2.15
Rectángulo{ color: “rojo” Flickable { anclajes.relleno: padre contentHeight: parent.height*2 contentWidth: parent.width clip: verdadero límitesBehavior:Flickable.StopAtBounds ScrollBar.vertical: ScrollBar { anclajes. arriba: parent.top anclajes.topMargin: -1 anclajes.derecho: padre.derecho ancho: 30 alto: padre.alto fondo: Rectángulo { color: "rojo" } contentItem: Rectángulo { implicitWidth: 10; Altura implícita: 10; color: “azul” } } } }
iimport QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.5
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
ScrollView
{
anchors.fill: parent
style:ScrollViewStyle{
handle: Rectangle {
implicitWidth: 50
implicitHeight: 30
color: "red"
}
scrollBarBackground: Rectangle {
implicitWidth: 50
implicitHeight: 30
color: "black"
}
decrementControl: Rectangle {
implicitWidth: 50
implicitHeight: 30
color: "green"
}
incrementControl: Rectangle {
implicitWidth: 50
implicitHeight: 30
color: "blue"
}
}
ListView{
anchors.fill: parent
delegate: Rectangle
{
width: parent.width-14
height: innerText.contentHeight+20
color: (index%2 === 0) ? "#252525" :"#000000"
Text
{
id: innerText
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
text: "name: " + modelData.name + "age: " + modelData.age
wrapMode: Text.WrapAnywhere
font.pixelSize: 14
color: "#ffffff"
}
}
model:[
{"name":"lilei","age":"20"},
{"name":"hanmeimei","age":"15"},
{"name":"lilei","age":"20"},
{"name":"hanmeimei","age":"15"},
{"name":"lilei","age":"20"},
{"name":"hanmeimei","age":"15"},
{"name":"lilei","age":"20"},
{"name":"hanmeimei","age":"15"},
{"name":"lilei","age":"20"},
{"name":"hanmeimei","age":"15"},
{"name":"lilei","age":"20"},
{"name":"hanmeimei","age":"15"},
{"name":"lilei","age":"20"},
{"name":"hanmeimei","age":"15"},
{"name":"lilei","age":"20"},
{"name":"hanmeimei","age":"15"},
{"name":"lilei","age":"20"},
{"name":"hanmeimei","age":"15"},
{"name":"wangbin","age":"22"}]
}
}
}
Por resolver: la posición del control deslizante volverá a la parte superior al cambiar de página