Unsolved View with one model item
-
Hi,
is there a way to display one item from model per page? When user clicks next button, next item from model is loaded into to the page.I know ListVIew, but it displays all items from model.
-
You mean smiliar to this?
import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Hello World") ListModel { id: fruitModel ListElement { name: "Apple" } ListElement { name: "Orange" } ListElement { name: "Banana" } } Row { id: myRow anchors.centerIn: parent spacing: 10 property int currentItem: 0 Label { width: 100 text: fruitModel.get(myRow.currentItem).name } Button { text: "Next" onClicked: myRow.currentItem = (myRow.currentItem < fruitModel.count - 1) ? ++myRow.currentItem : 0 } } }
-
You don't need listview. Also there is nothing like u need to use model with view only. As @Wieland suggested you can directly fetch data from model and display it
-
@MartinD StackView may be what you want. Both Controls 1 and 2 have their own StackView.
-
@dheerendra Could you elaborate on how one would go about directly fetching data from a C++ model using the user roles that are present in the model ?
@Eeli-K Wouldn't StackView also load all the items in the model? I mean, every time you push "next" the next item will be pushed onto the stack, so if you push next 30 times you'll have 30 items in the stack, and I think @MartinD wants that 1 item will be loaded at any given time. Also how would one go about accessing the models USER ROLES in a stackview ?