Results 1 to 2 of 2

Thread: Get value from single columned table when clicked on

  1. #1
    Join Date
    Nov 2015
    Posts
    2
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Get value from single columned table when clicked on

    After some research I get this far but now I don't know why the value doesn't show up. Any help?

    Qt Code:
    1. TableView {
    2. id: view
    3.  
    4. anchors.margins: 10
    5. anchors.fill: parent
    6. model: dataModel
    7. clip: true
    8.  
    9. TableViewColumn {
    10. width: 100
    11. title: "Name"
    12. role: "fileName"
    13. }
    14.  
    15. itemDelegate: Item {
    16. Text {
    17. anchors.left: parent.left
    18. anchors.verticalCenter: parent.verticalCenter
    19. renderType: Text.NativeRendering
    20. text: styleData.value
    21. }
    22. }
    23.  
    24. MouseArea
    25. {
    26. anchors.fill: parent
    27. acceptedButtons: Qt.LeftButton
    28. propagateComposedEvents: true
    29.  
    30. onPressed:
    31. {
    32.  
    33. if(mouse.button == Qt.LeftButton){
    34. console.log(view.value) // ??? styleData.value doen't work neihter
    35. }
    36. mouse.accepted = false
    37. }
    38. onReleased: mouse.accepted = false
    39. onPressAndHold: mouse.accepted = false
    40. }
    41. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by kristian1112; 21st November 2015 at 22:10.

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

    Default Re: Get value from single columned table when clicked on

    You want to have the mouse area inside the delegate.

    Cheers,
    _

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

    kristian1112 (22nd November 2015)

Similar Threads

  1. Replies: 3
    Last Post: 5th July 2016, 17:13
  2. Replies: 8
    Last Post: 10th July 2015, 13:12
  3. Multiple table delegates or a single table delegate?
    By karankumar1609 in forum Qt Programming
    Replies: 2
    Last Post: 22nd August 2014, 22:28
  4. multiple table in a single variable
    By sattu in forum Qt Programming
    Replies: 0
    Last Post: 1st March 2011, 12:01
  5. Replies: 1
    Last Post: 19th May 2010, 16:10

Tags for this Thread

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.