Results 1 to 3 of 3

Thread: get all row data from a selected row

  1. #1
    Join Date
    Apr 2011
    Posts
    67
    Thanks
    22
    Thanked 5 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default get all row data from a selected row

    I want to list tables in a database and i have the following columns.

    id | table_name | date_created | table_size


    I want to highlight the entire row and not a single cell.How can i get the all the data of a selected row,i.e the currently selected id,table_name,date_created,table_size.
    Last edited by thefatladysingsopera; 3rd May 2011 at 12:24.

  2. #2
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Get a specific column name from a selected row,click anywhere on the selected row

    Try this:
    Qt Code:
    1. int row = TreeView->currentIndex().row();
    2.  
    3. for (int i = 0; i < TreeView->model()->columnCount(); ++i)
    4. QString fileName = TreeView->model()->data( TreeView->model()->index(row, i) ).toString();
    To copy to clipboard, switch view to plain text mode 
    Last edited by Jonny174; 3rd May 2011 at 12:29.

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

    thefatladysingsopera (3rd May 2011)

  4. #3
    Join Date
    Sep 2008
    Location
    Poland
    Posts
    80
    Thanks
    4
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Get a specific column name from a selected row,click anywhere on the selected row

    First,select set selection behaviour of your view to QAbstractItemView::SelectRows
    Second,the best way to obtain a whole row from QSqlTableModel it the record function;

  5. The following user says thank you to MasterBLB for this useful post:

    thefatladysingsopera (3rd May 2011)

Similar Threads

  1. QComboBox: how to get selected value?
    By Ivan Khromov in forum Newbie
    Replies: 4
    Last Post: 2nd April 2011, 13:05
  2. Getting the selected row
    By k12yp70n in forum Newbie
    Replies: 4
    Last Post: 4th June 2009, 16:01
  3. How to tell which row is selected in a QtreeView
    By Valheru in forum Qt Programming
    Replies: 2
    Last Post: 9th November 2007, 22:10
  4. Selected window
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 25th October 2007, 13:03
  5. [QT4] Selected row in a QTreeWidget
    By vfernandez in forum Qt Programming
    Replies: 3
    Last Post: 9th March 2006, 11:54

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.