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. Qt6, save TableView record in the database
Forum Updated to NodeBB v4.3 + New Features

Qt6, save TableView record in the database

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt6
4 Posts 2 Posters 317 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.
  • M Offline
    M Offline
    MyNick 0
    wrote on last edited by MyNick 0
    #1

    I am adding a new entry to my TableView so: ```
    model->insertRow(model->rowCount());

    ![alt text](https://ddgobkiprc33d.cloudfront.net/fee3e98f-d1b0-4887-94a6-72c7e8f926e0.png)
    
    And then I fill all the cells.
    How can I now save this data in the database?
    Christian EhrlicherC 1 Reply Last reply
    0
    • M MyNick 0

      I am adding a new entry to my TableView so: ```
      model->insertRow(model->rowCount());

      ![alt text](https://ddgobkiprc33d.cloudfront.net/fee3e98f-d1b0-4887-94a6-72c7e8f926e0.png)
      
      And then I fill all the cells.
      How can I now save this data in the database?
      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @MyNick-0 said in Qt6, save TableView record in the database:

      How can I now save this data in the database?

      Read the data out of your model and create a QSqlQuery to put it into your database

      Or use a QSqlQueryModel in the first place.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MyNick 0
        wrote on last edited by
        #3

        How can I consider the data from the model can you bring the code?

        Christian EhrlicherC 1 Reply Last reply
        0
        • M MyNick 0

          How can I consider the data from the model can you bring the code?

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @MyNick-0 said in Qt6, save TableView record in the database:

          How can I consider the data from the model

          You set data with setData() and retrieve it with data() as you should already know - if not please read the documentation about Qt's model/view framework

          can you bring the code?

          I don't write code for others when they don't provide code by themself in the first place so I see that they thought about the problem and tried things out by themself.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1

          • Login

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