Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How can I use QSqlTableModel and QTableView to insert rows into a table?

    General and Desktop
    1
    2
    4969
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      Jonathan last edited by

      The CachedTable example (http://doc.qt.nokia.com/4.7/sql-cachedtable.html) shows how QSqlTableModel and QTableView can be used to display a table from a database and to update information in existing rows.

      Is it possible to use these classes to insert rows into the displayed table? Or do I have to create a separate SQL INSERT query?

      1 Reply Last reply Reply Quote 0
      • J
        Jonathan last edited by

        Posting the question led me to the answer.

        I'd missed QAbstractItemModel::insertRow().

        Works a treat.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post