Results 1 to 4 of 4

Thread: QML tableView : row is slected ?

  1. #1
    Join Date
    Jan 2016
    Posts
    54
    Thanks
    7
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QML tableView : row is slected ?

    Hii everyone,

    I have a TableView, and I want to delete a row
    First you must select a row and click on Button delete
    If the row is not selected ---> msg : No row is selected

    My question is : Is there a way to know if the row is selected or no ???

  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: QML tableView : row is slected ?

    You can access the view's selection via its "selection" property.
    In case you also make the selected row the current row, e.g. through code in the cell's delegate, the you could also check "currentRow"

    Cheers,
    _

  3. #3
    Join Date
    Jan 2016
    Posts
    54
    Thanks
    7
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QML tableView : row is slected ?

    Is the view.currentRow always returns = -1, IF no Row is selected ??

    For me, the code below works fine

    Qt Code:
    1. if(view.currentRow == -1){
    2. console.log("No Row is selected !!")
    3. }
    4. else{
    5. console.log("Row is selected OK")
    6. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    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: QML tableView : row is slected ?

    currentRow is not related to selection unless your code makes it so.

    Do you set currentRow, e.g. in side the delegate?

    Cheers,
    _

Similar Threads

  1. Using tableview with CSV
    By akshaysulakhe in forum Qt Programming
    Replies: 3
    Last Post: 19th July 2013, 09:28
  2. [Qt] TableView and QSqlQueryModel
    By Xandareva in forum Newbie
    Replies: 5
    Last Post: 7th April 2010, 14:20
  3. tableview
    By GuL in forum Newbie
    Replies: 1
    Last Post: 26th August 2008, 17:18
  4. help in tableview
    By bala in forum Qt Programming
    Replies: 3
    Last Post: 12th November 2007, 15:46
  5. Widgets in TableView
    By boonie in forum Qt Programming
    Replies: 4
    Last Post: 21st February 2006, 19:55

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
  •  
Qt is a trademark of The Qt Company.