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. how to access properties in a delegate
QtWS25 Last Chance

how to access properties in a delegate

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qt 5.7qmldelegateqt quick
4 Posts 3 Posters 687 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.
  • V Offline
    V Offline
    vinaygopal
    wrote on 5 Oct 2021, 14:52 last edited by vinaygopal 10 May 2021, 17:54
    #1

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

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

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

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dheerendra
      Qt Champions 2022
      wrote on 6 Oct 2021, 05:40 last edited by
      #2

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

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      V 1 Reply Last reply 6 Oct 2021, 10:14
      0
      • D dheerendra
        6 Oct 2021, 05:40

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

        V Offline
        V Offline
        vinaygopal
        wrote on 6 Oct 2021, 10:14 last edited by
        #3

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

        B 1 Reply Last reply 6 Oct 2021, 14:18
        0
        • V vinaygopal
          6 Oct 2021, 10:14

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

          B Offline
          B Offline
          Bob64
          wrote on 6 Oct 2021, 14:18 last edited by
          #4

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

          1 Reply Last reply
          1

          1/4

          5 Oct 2021, 14:52

          • Login

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