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. Referencing Column from a delegate
Forum Update on Monday, May 27th 2025

Referencing Column from a delegate

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
delegate
4 Posts 2 Posters 639 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.
  • G Offline
    G Offline
    gabor53
    wrote on last edited by
    #1

    Hi,
    I am trying to reference a column in a SimpleRow delegate from a SimpleSection:

    import Felgo 3.0
    import QtQuick 2.9
    import QtQuick.Controls 2.5
    import QtQuick.Controls.Styles 1.4
    import QtQuick.LocalStorage 2.12
    import "Database.js" as JS
    
    App {
    
        AppListView {
            id: myListView
            anchors.fill: parent
    
            model: ListModel {
                id: listModel
            }
    
            delegate: SimpleRow {
                Column {
                    id: wordColumn
                    visible: false
    
                    AppText {
                        text: model.wordField
                        x: dp(10)
                    }
                }
            }
    
            section.property: "sectionField"
            section.delegate: SimpleSection {
                enabled: true
                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        console.debug("letter clicked")
                        wordColumn.visible = !wordColumn.visible
                    }
                }
            }
        }
    
        Component.onCompleted: {
            JS.dbGetWordList()
        }
    }
    
    

    When I run it I get the following error message:
    ReferenceError: wordColumn is not defined
    I assume this is not the right way to reference it from SimpleSection. Please help me to make it correct. Thank you for your help.

    raven-worxR 1 Reply Last reply
    0
    • G gabor53

      Hi,
      I am trying to reference a column in a SimpleRow delegate from a SimpleSection:

      import Felgo 3.0
      import QtQuick 2.9
      import QtQuick.Controls 2.5
      import QtQuick.Controls.Styles 1.4
      import QtQuick.LocalStorage 2.12
      import "Database.js" as JS
      
      App {
      
          AppListView {
              id: myListView
              anchors.fill: parent
      
              model: ListModel {
                  id: listModel
              }
      
              delegate: SimpleRow {
                  Column {
                      id: wordColumn
                      visible: false
      
                      AppText {
                          text: model.wordField
                          x: dp(10)
                      }
                  }
              }
      
              section.property: "sectionField"
              section.delegate: SimpleSection {
                  enabled: true
                  MouseArea {
                      anchors.fill: parent
                      onClicked: {
                          console.debug("letter clicked")
                          wordColumn.visible = !wordColumn.visible
                      }
                  }
              }
          }
      
          Component.onCompleted: {
              JS.dbGetWordList()
          }
      }
      
      

      When I run it I get the following error message:
      ReferenceError: wordColumn is not defined
      I assume this is not the right way to reference it from SimpleSection. Please help me to make it correct. Thank you for your help.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @gabor53
      Thats because you trying to reference an id of an Component - which lives in its own context until an Item is created from it (which at the time the error occurs isn't the case yet in any runtime (parent) context.

      Anyway you should rather bind the visibility to a property of an Item which already exists, like on the AppListView itself, and toggle this property from the section.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      G 1 Reply Last reply
      1
      • raven-worxR raven-worx

        @gabor53
        Thats because you trying to reference an id of an Component - which lives in its own context until an Item is created from it (which at the time the error occurs isn't the case yet in any runtime (parent) context.

        Anyway you should rather bind the visibility to a property of an Item which already exists, like on the AppListView itself, and toggle this property from the section.

        G Offline
        G Offline
        gabor53
        wrote on last edited by
        #3

        Hi @raven-worx ,
        I bound the visibility to ApplistView. It works, but the whole page disappears when I click a section. Is there any other possible way of binding the visibility property? If possible to do this with SimpleSection please give me a little bit more detailed idea how to do it. Thank you for your help.

        raven-worxR 1 Reply Last reply
        0
        • G gabor53

          Hi @raven-worx ,
          I bound the visibility to ApplistView. It works, but the whole page disappears when I click a section. Is there any other possible way of binding the visibility property? If possible to do this with SimpleSection please give me a little bit more detailed idea how to do it. Thank you for your help.

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @gabor53
          i meant create a new custom property only for your purpose.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          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