Results 1 to 4 of 4

Thread: Can a QSqlModel be converted to a QStandardItemModel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2007
    Posts
    29
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Can a QSqlModel be converted to a QStandardItemModel

    Is there a more straightforward way to convert a QSqlModel to a QStandardItemModelOther than:
    Qt Code:
    1. qstandarditemmodel->insertRows(0, qsqlmodel->rowCount());
    2. qstandarditemmodel->insertColumns(0, qsqlmodel->columnCount());
    3. for(int c=0; c<qsqlmodel->columnCount(); c++)
    4. {
    5. qstandarditemmodel->setHeaderData(c, Qt::Horizontal, qsqlmodel->headerData(c, Qt::Horizontal));
    6. for(int r=0; r<qsqlmodel->rowCount(); r++)
    7. {
    8. qstandarditemmodel->setData(qstandarditemmodel->index(r, c), qsqlmodel->record(r).value(c));
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance
    Last edited by wysota; 21st March 2008 at 20:29. Reason: missing [code] tags

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.