Important: Please read the Qt Code of Conduct -

how to access properties in a delegate

  • lets say i have a tableview and i am using tableview column just like in the code.

            objectName: "favourite_table_view"
            width: 800
            height: 250
            model: fav_listModel
            property int updatedRow : -1
           console.log("the delegate visibility is", label1.width)
                      objectName: "ModuleName"
                      role: "module_name"
                      title: "Module Name"
                      width: fav_table_view.width/3
                      delegate: moduleName
               Item {
                   id: label1
                   objectName: "nameItem"
                   anchors.verticalCenter: parent.verticalCenter
                   Label {
                       anchors.verticalCenter: parent.verticalCenter
                       objectName: "registername"
                       text: styleData.value

    How do i get the width of the delegate element in the main tableview?

  • Qt Champions 2017

    How about giving the width for TableViewColumn only. This will be used for that delegate.

  • @dheerendra in this example i have given width, what if i want to access the visibility or a property i have defined in the delegate?

  • @vinaygopal

    "what if i want to access the visibility or a property i have defined in the delegate?"

    There are multiple instances of your delegate, corresponding to the part of the model being displayed. Which instance do you want the property from? If it's a common property that is not specific to a single instance, then the same answer applies - factor it out to the table level and use it in the delegate. If it is a property specific to a delegate instance you are interested in, how do you specify which delegate? Does the data actually belong to the model?

    What is it that you are trying to achieve?