Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I use QSqlTableModel and QTableView to insert rows into a table?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 5.1k Views
  • 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 Offline
    J Offline
    Jonathan
    wrote on last edited by
    #1

    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
    0
    • J Offline
      J Offline
      Jonathan
      wrote on last edited by
      #2

      Posting the question led me to the answer.

      I'd missed QAbstractItemModel::insertRow().

      Works a treat.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved