Results 1 to 4 of 4

Thread: read sqlite to array

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #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: read sqlite to array

    Lets assume you take the first approach

    You get the model
    Qt Code:
    1. QAbstractItemModel *model = tableView->model();
    To copy to clipboard, switch view to plain text mode 

    To get the number of rows use QAbstractItemModel::rowCount()
    Qt Code:
    1. const int rowCount = model->rowCount();
    To copy to clipboard, switch view to plain text mode 

    Now you loop over all rows.
    For each row you either loop over the columns or address them specifically
    Qt Code:
    1. QModelIndex index = model->index(currentRow, 0); // first column;
    To copy to clipboard, switch view to plain text mode 

    You get the displayed text of a cell from the QModelIndex
    Qt Code:
    1. QString text = index.data(Qt::DisplayRole).toString();
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

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

    vanduongbk (2nd October 2013)

Similar Threads

  1. Replies: 2
    Last Post: 26th March 2011, 04:29
  2. read ini file content and save into array
    By cooper in forum Newbie
    Replies: 8
    Last Post: 14th March 2011, 21:33
  3. read a .txt file and store it in a double array
    By fatecasino in forum Newbie
    Replies: 5
    Last Post: 3rd December 2010, 20:13
  4. read from file into array
    By obad in forum Qt Programming
    Replies: 1
    Last Post: 1st August 2010, 08:26
  5. sqlite read lock.
    By gilgm in forum Qt Programming
    Replies: 6
    Last Post: 18th June 2010, 05:58

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.