Results 1 to 6 of 6

Thread: Select current row in TableView through custom itemDelegate

  1. #1
    Join Date
    Apr 2014
    Location
    PÅ‚ock, Poland
    Posts
    13
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Select current row in TableView through custom itemDelegate

    I create custom itemDelegate, but when i click left mouse button, the row isn't selected. How can I do it in custom itemDelegate?
    Qt Code:
    1. itemDelegate:Item{
    2. MouseArea
    3. {
    4. anchors.fill: parent
    5. onClicked: ;//select current row
    6. onDoubleClicked: {
    7. hideAll();
    8. mainconversationForm.visible=true
    9. mainconversationForm.numberTel=tableXMLModel.get(mainTable.currentRow).numersms
    10. // console.log(tableXMLModel.get(mainTable.currentRow).numersms);
    11. }
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Select current row in TableView through custom itemDelegate

    Did you put anything in the onClicked handler or is it empty like in the code you posted? If latter is the case then why are you surprised that selection doesn't work if you are not performing any selection?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2014
    Location
    PÅ‚ock, Poland
    Posts
    13
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Select current row in TableView through custom itemDelegate

    I add onClicked because I wanted to show where I have a problem. I ask how I can handle onClick to select current row in TableView

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Select current row in TableView through custom itemDelegate

    e.g.
    javascript Code:
    1. onClicked: view.selection.select(index)
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Apr 2014
    Location
    PÅ‚ock, Poland
    Posts
    13
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Select current row in TableView through custom itemDelegate

    But How to get index Element by mouse ?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Select current row in TableView through custom itemDelegate

    Each delegate instance gets its index from the view. Just call "index" in the delegate root item and it will return the index of the item in the model.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    updaterr (9th June 2014)

Similar Threads

  1. Issue with custom delegate in tableview
    By alizadeh91 in forum Qt Programming
    Replies: 4
    Last Post: 13th April 2013, 08:39
  2. Replies: 0
    Last Post: 25th February 2013, 02:00
  3. display custom widget in a TableView
    By code_talker in forum Qt Programming
    Replies: 4
    Last Post: 4th August 2012, 21:40
  4. custom tableview
    By dubstar_04 in forum Qt Programming
    Replies: 0
    Last Post: 10th April 2011, 17:33
  5. getting current Id from tableView
    By mkarakaplan in forum Newbie
    Replies: 3
    Last Post: 7th October 2007, 22:14

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.