Unsolved problem with ListView
-
Hello everybody,
I have in a QQmlListProperty (firstQml) an other QQmlListProperty (secondQml), so in the main.qml I have :
FirstQQml{ ListView{ model : firstqmlList // it is a list of name and there is the second QQmlListproperty delegate: persoButton{ Text{ text: name} } } } SecondQQml{ ListView{ model : firstqmlList delegate: ListView{ model : secondQmlList // it is a list of number delegate: Text{ text : number } } } }
It works, but when I click on my list of persoButton, it doesn't change the number bound to name. How can I do that ?
I hope you understood my problem
thanks a lot.
-
Is it not possible to do what I want to do ?
-
@cosmoff can you be more specific with what you want to happen, I can't quite follow.
-
for example :
I have a serie of name in the firstQQmlpaul
sam
luc
jordan
mikeand in the secondQQml, I have a list of number
10
5
6this numbers 10-5-6 are bound at the name paul. and the numbers 1-25-3 are bound at the name sam. But when I click on the name sam the numbers don't change.
When I change of name by clicking on the name sam, I would like change the display of number in the second ListView
-
@cosmoff
you mean, something like this ?import QtQuick 2.12 import QtQuick.Controls 2.5 ApplicationWindow { visible:true width:500; height:500 ListView{ id: view1 model: ["Paul", "Franz", "Karl"] anchors.left: parent.left anchors.right: parent.horizontalCenter anchors.top: parent.top anchors.bottom: parent.bottom delegate: Button{ text: modelData onClicked:{ console.log("clicked",text) view2.newModel(index) } } } ListView{ id: view2 model: [1, 2, 3] function newModel( index){ switch(index){ default: case 0: view2.model = [1,2,3]; break; case 1: view2.model = [4,5,6];break; case 2: view2.model = [7,8,9];break; } } anchors.right: parent.right anchors.left: parent.horizontalCenter anchors.top: parent.top anchors.bottom: parent.bottom delegate: Text{ text: modelData } } }
-
@J.Hilk yes exactly ! but how can I have the same result with the code in my main.qml ?
-
@cosmoff
well you'll have to adapt my example.The key is, that the model of
SecondQQml
is changed when you click on the button on your first ListView -
I am totally lost, how can I do that, because my model is a QQmlListProperty
-
ok I understood thanks for your help