Developer
Kirigami.ScrollablePage
A ScrollablePage is a Page that holds scrollable content, such as ListViews. Scrolling and scrolling indicators will be automatically managed.
ScrollablePage {
id: root
//The rectangle will automatically be scrollable
Rectangle {
width: root.width
height: 99999
}
}
If a ScrollablePage contains a single direct child item and this child item is a ListView when the ListView covers the entire page and adds a scrollbar to the right.
Two scrollable pages containing both a ListView with custom contents (Screenshot of NeoChat)
Often you have more than one child in your ScrollablePage, there are two ways to fix this.
It is possible to add a Placeholder Message with some instructions in case the list view is empty.
Kirigami.ScrollablePage {
ListView {
id: listView
Kirigami.PlaceholderMessage {
anchors.centerIn: parent
width: parent.width - (Kirigami.Units.largeSpacing * 4)
visible: listView.count === 0
text: i18n("No data found")
helpfulAction: Kirigami.Action {
text: i18n("Load data")
...
}
}
model: ...
}
}
A search field is often added to a ScrollablePage to filter the ListView.
This can be done by changing the default titleDelegate
to use a
Kirigami.SearchField
instead.
Kirigami.ScrollablePage {
titleDelegate: Kirigami.SearchField {
Layout.topMargin: Kirigami.Units.smallSpacing
Layout.bottomMargin: Kirigami.Units.smallSpacing
Layout.fillHeight: true
Layout.fillWidth: true
onTextChanged: mySortFilterModel.filterText = text
KeyNavigation.tab: listView
}
ListView {
id: listView
...
}
}
Another behavior added by this class is a “pull to refresh” behavior. To use this, activate it as follows:
Kirigami.ScrollablePage {
id: view
supportsRefreshing: true
onRefreshingChanged: {
if (refreshing) {
myModel.refresh();
}
}
ListView {
// NOTE: MyModel doesn't come from the components,
// it's purely an example on how it can be used together
// some application logic that can update the list model
// and signals when it's done.
model: MyModel {
onRefreshDone: view.refreshing = false;
}
delegate: BasicListItem {}
}
}
By pulling down, you can also activate a special mode with a larger top margin making single-handed usage of the application easier.