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. Commication between two qml files with repeater/list view
Forum Updated to NodeBB v4.3 + New Features

Commication between two qml files with repeater/list view

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 191 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.
  • P Offline
    P Offline
    Prajwal
    wrote on 30 Dec 2022, 10:53 last edited by
    #1

    I'm developing an app and I am new to qml, I want to change the color of a rectangle when the particular button is clicked from another page, the rectangles are dynamic, I might use list view or repeater to call the 2nd page, number rect in page 2 = number of buttons in page1.

    page1:

    ListView {
                id: sprayerSettingsListView
                anchors.fill: parent
                model: sprayerSettingListModelId
                orientation: Qt.Horizontal
                interactive: false
                delegate: Booms_test { // another page
                    onClickedBoom: sprayerSettingsListView.currentIndex = index
                    totalListElement: sprayerSettingsListView.count
                }
                focus: true
            }
    
    
    
    //list model
    
     ListElement {
                    rects: 10
                }
    

    page2:

     Row {
                    spacing:10
                    Repeater {
                        id: nozzlerRepeater
                        model: rects 
                        Rectangle {
                            id: smallNozlesRectId
                            height: 15
                            width: 10
                            color: "green"
                        }
                    }
                }
    

    here I have 10 rects (from repeater/ list view) and 10 buttons in page 1 how do I change color of rect 1 in page 2 when butoon 1 clicked in page 1 ?

    B 1 Reply Last reply 30 Dec 2022, 12:47
    0
    • P Prajwal
      30 Dec 2022, 10:53

      I'm developing an app and I am new to qml, I want to change the color of a rectangle when the particular button is clicked from another page, the rectangles are dynamic, I might use list view or repeater to call the 2nd page, number rect in page 2 = number of buttons in page1.

      page1:

      ListView {
                  id: sprayerSettingsListView
                  anchors.fill: parent
                  model: sprayerSettingListModelId
                  orientation: Qt.Horizontal
                  interactive: false
                  delegate: Booms_test { // another page
                      onClickedBoom: sprayerSettingsListView.currentIndex = index
                      totalListElement: sprayerSettingsListView.count
                  }
                  focus: true
              }
      
      
      
      //list model
      
       ListElement {
                      rects: 10
                  }
      

      page2:

       Row {
                      spacing:10
                      Repeater {
                          id: nozzlerRepeater
                          model: rects 
                          Rectangle {
                              id: smallNozlesRectId
                              height: 15
                              width: 10
                              color: "green"
                          }
                      }
                  }
      

      here I have 10 rects (from repeater/ list view) and 10 buttons in page 1 how do I change color of rect 1 in page 2 when butoon 1 clicked in page 1 ?

      B Offline
      B Offline
      Bob64
      wrote on 30 Dec 2022, 12:47 last edited by
      #2

      @Prajwal what do you mean by pages here? I assume these components are managed by some top level component in which they are treated as "pages"? If that's the case, can you make the connections at that higher level? i.e bind a property or signal from one page to the other page?

      1 Reply Last reply
      0

      1/2

      30 Dec 2022, 10:53

      • Login

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