Results 1 to 3 of 3

Thread: QTableView without QSqlQueryModel or QSqlTableModel

  1. #1
    Join Date
    Nov 2009
    Posts
    68
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded

    Default QTableView without QSqlQueryModel or QSqlTableModel

    I have some data that is coming in via a TCP/IP connection that I need to show in a QTableView. I don't need to create a DB for the information. What is the best way to show this information in a QTableView if I don't want a DB.

    I could show the information in QListView if I could set up Tabs.

  2. #2
    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: QTableView without QSqlQueryModel or QSqlTableModel

    If you need a model based approach then write your own model and add the data there. Or just use QTableWidget and add items whenever you receive data.

  3. #3
    Join Date
    Apr 2009
    Posts
    35
    Thanks
    9
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Android

    Default Re: QTableView without QSqlQueryModel or QSqlTableModel

    1 Code:
    1. QStandardItem *newItem=0;
    2. QStandardItemModel *model = new QStandardItemModel();
    3.  
    4.  
    5. for(int row=0; row< datarow.count() ; row++){
    6. for(int col=0; col< datacol.count() ; col++){
    7. newItem = new QStandardItem(yourdata.toString());
    8. model->setItem(row ,col, newItem);
    9. }
    10. row++;
    11. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. SQL transactions with QSqlQueryModel/QTableView
    By estanisgeyer in forum Qt Programming
    Replies: 2
    Last Post: 15th June 2009, 18:52
  2. QTableView/QSqlQueryModel
    By norobro in forum Qt Programming
    Replies: 7
    Last Post: 15th February 2008, 21:52
  3. QTableView, QSqlQueryModel and delegates
    By estanisgeyer in forum Qt Programming
    Replies: 1
    Last Post: 29th January 2008, 12:04
  4. QSqlTableModel/QSqlQueryModel
    By dragon in forum Newbie
    Replies: 11
    Last Post: 14th December 2006, 15:37
  5. metadata in a QSqlQueryModel/QTableView?
    By gfunk in forum Qt Programming
    Replies: 3
    Last Post: 13th July 2006, 22:13

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.