Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. problem with ListView
Forum Updated to NodeBB v4.3 + New Features

problem with ListView

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
9 Posts 2 Posters 999 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cosmoff
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cosmoff
      wrote on last edited by
      #2

      Is it not possible to do what I want to do ?

      J.HilkJ 1 Reply Last reply
      0
      • C cosmoff

        Is it not possible to do what I want to do ?

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @cosmoff can you be more specific with what you want to happen, I can't quite follow.


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cosmoff
          wrote on last edited by cosmoff
          #4

          for example :
          I have a serie of name in the firstQQml

          paul
          sam
          luc
          jordan
          mike

          and in the secondQQml, I have a list of number

          10
          5
          6

          this 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

          J.HilkJ 1 Reply Last reply
          0
          • C cosmoff

            for example :
            I have a serie of name in the firstQQml

            paul
            sam
            luc
            jordan
            mike

            and in the secondQQml, I have a list of number

            10
            5
            6

            this 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

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @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
                    }
                }
            }
            
            

            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            C 1 Reply Last reply
            0
            • J.HilkJ J.Hilk

              @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
                      }
                  }
              }
              
              
              C Offline
              C Offline
              cosmoff
              wrote on last edited by
              #6

              @J.Hilk yes exactly ! but how can I have the same result with the code in my main.qml ?

              J.HilkJ 1 Reply Last reply
              0
              • C cosmoff

                @J.Hilk yes exactly ! but how can I have the same result with the code in my main.qml ?

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                @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


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                C 1 Reply Last reply
                0
                • J.HilkJ J.Hilk

                  @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

                  C Offline
                  C Offline
                  cosmoff
                  wrote on last edited by cosmoff
                  #8

                  I am totally lost, how can I do that, because my model is a QQmlListProperty

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    cosmoff
                    wrote on last edited by
                    #9

                    ok I understood thanks for your help

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved