Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QML Table View with itemdelegate and row delegate
Forum Updated to NodeBB v4.3 + New Features

QML Table View with itemdelegate and row delegate

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 857 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.
  • R Offline
    R Offline
    Rich Bair
    wrote on last edited by
    #1

    Currently have the table view connected to QSqlQueryModel and fetching data.

    I use rowdelegate to create an expansion like so:

                rowDelegate: Item {
                    id: tvRowDelegate
                    height: 65
                    state: "collapsed"
                    states:
                      [
                        State {
                            name: "collapsed"
                            PropertyChanges { target: tvRowDelegate; height: 65; }
                        },
                        State {
                            name: "expanded"
                            PropertyChanges { target: tvRowDelegate; height: 100; }
                         }
                      ]
                    MouseArea {
                        anchors.fill: parent
                        onClicked: {
                            tvRowDelegate.state = (tvRowDelegate.state === "collapsed") ? "expanded" : "collapsed";
                        }
                    }
                }
    

    And I want to combined two columns of text for when I "drop down" or expand the row:

                itemDelegate:  Rectangle {
                    id: eventItem
                    width: parent.width
                    height: 65
                    color: "#ECEEEE"
                    Text {
                        id: txtItm
                        height: 55
                        leftPadding: 5
                        //TODO
                        text: ((styleData.column === 0) ? formatDT(styleData.value) : ((styleData.column === 1) ? styleData.value : ((eventLogView.height === 65) ? styleData.value : sqlELmodel.combineColums(styleData.row, 2, 3))))
                        //text: ((styleData.column === 0) ? formatDT(styleData.value) : ((styleData.column === 1) ? styleData.value : styleData.value))
                        font.pixelSize: 19
                        font.family: "NotoSans"
                        horizontalAlignment: Qt.AlignLeft
                        verticalAlignment: Qt.AlignVCenter
                        elide: Qt.ElideRight
                    }
                    Rectangle {
                        width: parent.width
                        height: 10
                        color: "#FFFFFF"
                    }
                }
    

    But the item delegate does not seem to be able to access the state variable of the row delegate. Not am I able to try to sense the height of the expanded row. Thoughts on how to solve this issue?

    Thanks,
    -Rich

    1 Reply Last reply
    0
    • PendletonicP Offline
      PendletonicP Offline
      Pendletonic
      wrote on last edited by
      #2

      Delegates are Components which means, their ids do not reference any specific instance of the delegate. Because of this you cannot query properties or get any kind of state data by using ids or referring to the itemDelegate or rowDelegate properties.

      I would typically resolve this kind of thing by adding an expanded bool property into the model. Then set your states to switch using a "when:" clause (to avoid the string comparison logic which is slower) and you should be able to switch your SQL data based on this value as well.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rich Bair
        wrote on last edited by
        #3

        Hmmm, let me research some more on that. If the model is a QSqlModelQuery not quite sure how to expand the model.

        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