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. Treeview with delegate in a different file and inline MouseArea
Forum Update on Monday, May 27th 2025

Treeview with delegate in a different file and inline MouseArea

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 1 Posters 961 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
    Valerian
    wrote on 15 Jun 2016, 08:29 last edited by
    #1

    Hi All,

    I have a TreeView as shown here

    
    TreeView {
        
        id:treeView
        anchors.fill: parent
        model: treemodel
        
        TableViewColumn {
            title: "Name"
            role: "name"
            
            delegate: EditableDelegate{
                MouseArea {
                    id: columnMouseArea
                    anchors.fill: parent
                    acceptedButtons: Qt.RightButton
                    propagateComposedEvents: true
                    onClicked: {
                        console.log("Test")
                    }
                }
            }
        }
    }
    

    The EditableDelegate is defined in a different file

    Item{
        Text {
            id: label
            text: model.name
            color: "blue"
            font.family: "Open Sans"
            verticalAlignment: Text.AlignVCenter
            anchors.leftMargin: 5
            elide: "ElideRight"
            anchors.verticalCenter: parent.verticalCenter
            width: parent.width
        }
    }
    

    However, I get the following error "Cannot assign to non-existent default property" at the treeview where the Mouse area is defined

    I need the following design as I want to reuse the delegate with another treeview
    Could you suggest a workaround for this approach?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Valerian
      wrote on 16 Jun 2016, 04:31 last edited by
      #2

      Is it possible to have an inline MouseArea for a delegate defined in a seperate file?

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Valerian
        wrote on 17 Jun 2016, 06:17 last edited by
        #3

        Found the solution, the EditableDelegate in the treeview needed a height and width.

        1 Reply Last reply
        0

        1/3

        15 Jun 2016, 08:29

        • 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