Results 1 to 3 of 3

Thread: Treeview with delegate in a different file and inline MouseArea

  1. #1
    Join Date
    Jan 2010
    Posts
    95
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Treeview with delegate in a different file and inline MouseArea

    Hi All,

    I have a TreeView as shown here

    Qt Code:
    1. TreeView {
    2.  
    3. id:treeView
    4. anchors.fill: parent
    5. model: treemodel
    6.  
    7. TableViewColumn {
    8. title: "Name"
    9. role: "name"
    10.  
    11. delegate: EditableDelegate{
    12. MouseArea {
    13. id: columnMouseArea
    14. anchors.fill: parent
    15. acceptedButtons: Qt.RightButton
    16. propagateComposedEvents: true
    17. onClicked: {
    18. console.log("Test")
    19. }
    20. }
    21. }
    22. }
    23. }
    To copy to clipboard, switch view to plain text mode 

    The EditableDelegate is defined in a different file

    Qt Code:
    1. Item{
    2. Text {
    3. id: label
    4. text: model.name
    5. color: "blue"
    6. font.family: "Open Sans"
    7. verticalAlignment: Text.AlignVCenter
    8. anchors.leftMargin: 5
    9. elide: "ElideRight"
    10. anchors.verticalCenter: parent.verticalCenter
    11. width: parent.width
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Treeview with delegate in a different file and inline MouseArea

    Interesting.

    Aside from your item not having any size, it should still have "children" as its default property.

    Does this also happen if you are using EditableDelegate as a normal element in a test file? I.e. not as a delegate?

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    volcano (16th June 2016)

  4. #3
    Join Date
    Jan 2010
    Posts
    95
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Treeview with delegate in a different file and inline MouseArea

    It works fine when used as a normal element instead of a delegate.

    Found a fix. Thanks for the tip regarding the size. I gave the delegate a fixed width and height and then it started working.
    Last edited by volcano; 16th June 2016 at 11:24.

Similar Threads

  1. why not works my mouseArea
    By kickoune in forum Qt Quick
    Replies: 3
    Last Post: 11th March 2016, 13:51
  2. MouseArea
    By Viper666 in forum Qt Quick
    Replies: 6
    Last Post: 10th January 2013, 13:30
  3. How to apply TreeView look & feel to a delegate?
    By estecb in forum Qt Programming
    Replies: 5
    Last Post: 15th March 2012, 12:01
  4. Replies: 2
    Last Post: 12th February 2010, 04:41
  5. Replies: 2
    Last Post: 24th September 2009, 00:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.