Results 1 to 5 of 5

Thread: Get Row Index

  1. #1
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Get Row Index

    First, sorry with my english.

    I have a QTableView with data like this..

    name | sex
    ----------------------
    Si a | M
    Si b | F
    Si c | F
    Si d | M
    Si e | F


    How to get row index in QTableView from data with name="Si c" and sex="F".

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Get Row Index

    If you are using QTableView and model, I guess you need to implement a search function yourself. You can match text using models function - QAbstractItemModel::data
    In case you are using QTableWidget, you can have a look at QTableWidget::findItems

  3. #3
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Re: Get Row Index

    Look, I need select a row in TableView. So far, I use selectRow function.

    ui->tableView->selectRow(rowindex);

    Now I need select row after click a pushbutton, but not know the row index. I only know, the row have data on colum name="Si c" and colomn sex="F"

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Get Row Index

    What model do you use and how do you populate that model?

  5. #5
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Re: Get Row Index

    I use QSqlQueryModel

    Qt Code:
    1. model->setQuery("select * from test");
    2.  
    3. ui->tableView->setModel(model);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QTreView::isExpanded ( index ) allways false ?
    By jpujolf in forum Qt Programming
    Replies: 3
    Last Post: 24th September 2010, 10:23
  2. Obtain index of child's parent
    By webquinty in forum Qt Programming
    Replies: 4
    Last Post: 11th May 2009, 11:57
  3. Replies: 3
    Last Post: 25th July 2008, 14:30
  4. QProcess readStdOut index
    By user_mail07 in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2008, 19:37
  5. Qtopia core 4.2.2 cross compile make error
    By smiyai18 in forum Installation and Deployment
    Replies: 2
    Last Post: 28th August 2007, 17:04

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.