ScrollIndicator QML Type
Vertikale oder horizontale nicht-interaktive Bildlaufanzeige. Mehr...
| Import Statement: | import QtQuick.Controls |
| Inherits: |
Eigenschaften
- active : bool
- horizontal : bool
(since QtQuick.Controls 2.3 (Qt 5.10)) - minimumSize : real
(since QtQuick.Controls 2.4 (Qt 5.11)) - orientation : enumeration
- position : real
- size : real
- vertical : bool
(since QtQuick.Controls 2.3 (Qt 5.10)) - visualPosition : real
(since QtQuick.Controls 2.4 (Qt 5.11)) - visualSize : real
(since QtQuick.Controls 2.4 (Qt 5.11))
Beigefügte Eigenschaften
- horizontal : ScrollIndicator
- vertical : ScrollIndicator
Detaillierte Beschreibung
ScrollIndicator ist ein nicht-interaktiver Indikator, der die aktuelle Bildlaufposition anzeigt. Ein ScrollIndicator kann entweder vertical oder horizontal sein und kann mit jedem Flickable verbunden werden, wie ListView und GridView.
Flickable { // ... ScrollIndicator.vertical: ScrollIndicator { } }
Anhängen von ScrollIndicator an ein Flickable
Hinweis: Wenn ScrollIndicator vertically oder horizontally an ein Flickable angehängt wird, werden seine Geometrie und die folgenden Eigenschaften automatisch festgelegt und entsprechend aktualisiert:
Ein angehängter ScrollIndicator ordnet sich selbst dem Ziel-Flickable zu. Ein vertikal angehängter ScrollIndicator passt seine Größe an die Höhe des Flickable an und positioniert sich auf der Grundlage von layout direction auf beiden Seiten desselben. Ein horizontal angehängter ScrollIndicator passt seine Größe an die Breite des Flickable an und positioniert sich am unteren Rand. Die automatische Geometrieverwaltung kann deaktiviert werden, indem ein anderes übergeordnetes Element für den angehängten ScrollIndicator angegeben wird. Dies kann z. B. nützlich sein, wenn der ScrollIndicator außerhalb eines Clipping Flickable platziert werden soll. Dies wird anhand des folgenden Beispiels demonstriert:
Flickable { id: flickable clip: true // ... ScrollIndicator.vertical: ScrollIndicator { parent: flickable.parent anchors.top: flickable.top anchors.left: flickable.right anchors.bottom: flickable.bottom } }
Binden des aktiven Zustands von horizontalen und vertikalen Scrollindikatoren
Horizontale und vertikale Scroll-Indikatoren teilen standardmäßig nicht den Status active miteinander. Um beide Indikatoren beim Scrollen in eine der beiden Richtungen sichtbar zu halten, müssen Sie eine wechselseitige Bindung zwischen den aktiven Zuständen herstellen, wie im folgenden Beispiel dargestellt:
Flickable { anchors.fill: parent contentWidth: parent.width * 2 contentHeight: parent.height * 2 ScrollIndicator.horizontal: ScrollIndicator { id: hbar; active: vbar.active } ScrollIndicator.vertical: ScrollIndicator { id: vbar; active: hbar.active } }
Nicht verbundene Bildlaufindikatoren
Es ist möglich, eine Instanz von ScrollIndicator zu erstellen, ohne die API für angehängte Eigenschaften zu verwenden. Dies ist nützlich, wenn das Verhalten des angehängten Scrollindikators nicht ausreicht oder eine Flickable nicht verwendet wird. Im folgenden Beispiel werden horizontale und vertikale Bildlaufindikatoren verwendet, um anzuzeigen, wie weit der Benutzer über den Text gescrollt hat (unter Verwendung von MouseArea anstelle von Flickable):
Rectangle { id: frame clip: true width: 160 height: 160 border.color: "black" anchors.centerIn: parent Text { id: content text: "ABC" font.pixelSize: 169 MouseArea { id: mouseArea drag.target: content drag.minimumX: frame.width - width drag.minimumY: frame.height - height drag.maximumX: 0 drag.maximumY: 0 anchors.fill: content } } ScrollIndicator { id: verticalIndicator active: mouseArea.pressed orientation: Qt.Vertical size: frame.height / content.height position: -content.y / content.height anchors { top: parent.top; right: parent.right; bottom: parent.bottom } } ScrollIndicator { id: horizontalIndicator active: mouseArea.pressed orientation: Qt.Horizontal size: frame.width / content.width position: -content.x / content.width anchors { left: parent.left; right: parent.right; bottom: parent.bottom } } }

Unterschiedliche Delegatengrößen
Variable Delegatengrößen können dazu führen, dass ScrollIndicator "herumspringt", wenn neue Delegaten in die Ansicht geladen werden. Aus diesem Grund wird empfohlen, gleich große Delegaten zu verwenden. Siehe Variable Delegate Size and Section Labels für weitere Informationen.
Siehe auch ScrollBar, Anpassen von ScrollIndicator und Indicator Controls.
Dokumentation der Eigenschaft
active : bool
Diese Eigenschaft gibt an, ob der Indikator aktiv ist, d.h. wenn das angehängte Flickable moving ist.
Es ist möglich, both horizontal and vertical indicators visible beim Scrollen in beide Richtungen beizubehalten.
Diese Eigenschaft wird automatisch gesetzt, wenn der Bildlaufindikator attached to a flickable ist.
horizontal : bool [read-only, since QtQuick.Controls 2.3 (Qt 5.10)]
Diese Eigenschaft legt fest, ob der Scroll-Indikator horizontal ist.
Diese Eigenschaft wurde in QtQuick.Controls 2.3 (Qt 5.10) eingeführt.
Siehe auch orientation.
minimumSize : real [since QtQuick.Controls 2.4 (Qt 5.11)]
Diese Eigenschaft enthält die Mindestgröße des Indikators, skaliert auf 0.0 - 1.0.
Diese Eigenschaft wurde in QtQuick.Controls 2.4 (Qt 5.11) eingeführt.
Siehe auch size, visualSize, und visualPosition.
orientation : enumeration
Diese Eigenschaft bestimmt die Ausrichtung des Indikators.
Mögliche Werte:
| Konstant | Beschreibung |
|---|---|
Qt.Horizontal | Horizontal |
Qt.Vertical | Vertikal (Standard) |
Diese Eigenschaft wird automatisch gesetzt, wenn der Bildlaufindikator attached to a flickable ist.
Siehe auch horizontal und vertical.
position : real
Diese Eigenschaft enthält die Position des Indikators, skaliert auf 0.0 - 1.0.
Diese Eigenschaft wird automatisch gesetzt, wenn der Bildlaufindikator attached to a flickable ist.
Siehe auch Flickable::visibleArea und visualPosition.
size : real
Diese Eigenschaft enthält die Größe des Indikators, skaliert auf 0.0 - 1.0.
Diese Eigenschaft wird automatisch gesetzt, wenn der Bildlaufindikator attached to a flickable ist.
Siehe auch Flickable::visibleArea, minimumSize, und visualSize.
vertical : bool [read-only, since QtQuick.Controls 2.3 (Qt 5.10)]
Diese Eigenschaft legt fest, ob der Scroll-Indikator vertikal ist.
Diese Eigenschaft wurde in QtQuick.Controls 2.3 (Qt 5.10) eingeführt.
Siehe auch orientation.
visualPosition : real [since QtQuick.Controls 2.4 (Qt 5.11)]
Diese Eigenschaft enthält die effektive visuelle Position des Indikators, die durch die minimum size begrenzt werden kann.
Diese Eigenschaft wurde in QtQuick.Controls 2.4 (Qt 5.11) eingeführt.
Siehe auch position und minimumSize.
visualSize : real [since QtQuick.Controls 2.4 (Qt 5.11)]
Diese Eigenschaft enthält die effektive visuelle Größe des Indikators, die durch die minimum size begrenzt werden kann.
Diese Eigenschaft wurde in QtQuick.Controls 2.4 (Qt 5.11) eingeführt.
Siehe auch size und minimumSize.
Dokumentation der Eigenschaft Attached
ScrollIndicator.horizontal : ScrollIndicator
Mit dieser Eigenschaft wird ein horizontaler Bildlaufindikator an eine Flickable angehängt.
Flickable { contentWidth: 2000 ScrollIndicator.horizontal: ScrollIndicator { } }
Siehe auch Attaching ScrollIndicator to a Flickable.
ScrollIndicator.vertical : ScrollIndicator
Mit dieser Eigenschaft wird ein vertikaler Bildlaufindikator an eine Flickable angehängt.
Flickable { contentHeight: 2000 ScrollIndicator.vertical: ScrollIndicator { } }
Siehe auch Attaching ScrollIndicator to a Flickable.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.