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. TableView rowDelegate how to take row index?
Forum Updated to NodeBB v4.3 + New Features

TableView rowDelegate how to take row index?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmltableviewrowdelegate
3 Posts 1 Posters 1.8k Views 1 Watching
  • 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
    Galbarad
    wrote on 16 Jan 2019, 13:09 last edited by
    #1
    import QtQuick 2.2
    import QtQuick.Controls 1.2
    import QtQuick.Controls 2.0
    import QtQuick.Dialogs 1.2
    
    TableView {
            id: tvMain
            
           rowDelegate: Rectangle {
                id: rdRow
                border.width: {
                    console.log("rowDelegate", styleData.row, styleData.value,
                                JSON.stringify(styleData) )
                    return 0
                }
    

    output is

    qml: rowDelegate undefined undefined {"objectName":"","alternate":true,"selected":false,"hasActiveFocus":false,"pressed":false}
    qml: rowDelegate undefined undefined {"objectName":"","alternate":false,"selected":false,"hasActiveFocus":false,"pressed":false}
    

    so, my question is:
    how I can take row index from rowDelegate? Looks like styleData.row not available(
    thanks

    1 Reply Last reply
    0
    • G Offline
      G Offline
      Galbarad
      wrote on 16 Jan 2019, 15:47 last edited by
      #2

      hmm, when row selected property "row" - available

      qml: rowDelegate {"objectName":"","row":0,"alternate":false,"selected":true,"hasActiveFocus":false,"pressed":true}
      qml: rowDelegate {"objectName":"","row":0,"alternate":false,"selected":true,"hasActiveFocus":false,"pressed":false}
      
      
      1 Reply Last reply
      0
      • G Offline
        G Offline
        Galbarad
        wrote on 23 Jan 2019, 06:56 last edited by
        #3

        but in MouseArea in row delegate styleData.row - available
        following code show right click menu for row in place where mouse clicked

        rowDelegate: Rectangle {
                    id: rdRow
                    height: 30
        
                    MouseArea {
                        id: maRow
                        anchors.fill: parent
                        acceptedButtons: Qt.RightButton
                        onClicked: {
                            console.log("right click on row", styleData.row, mouseX,
                                        mouseY, tvMain.flickableItem.contentY)
                            if ((styleData.row || (styleData.row === 0))
                                    && (mouse.button === Qt.RightButton)) {
                                currentRowIdxForMenu = styleData.row
                                cmRow.x = mouseX
                                cmRow.y = mouseY + styleData.row * rdRow.height
                                        - tvMain.flickableItem.contentY
                                cmRow.open()
                            }
                        }
                    }
                }
        
        1 Reply Last reply
        0

        1/3

        16 Jan 2019, 13:09

        • Login

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