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. QSqltableModel BeforeUpdate??
Forum Updated to NodeBB v4.3 + New Features

QSqltableModel BeforeUpdate??

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 919 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.
  • Z Offline
    Z Offline
    zeroptr
    wrote on last edited by
    #1

    Hi All,

    I have form with tableview its model is a QSqlTableModel... User inserts a record with insertrows.. After inserting user can leave some fields blank .. When he/she changes the row model inserts the data to database.. I want to prevent inserting wrong or blank data to database beforeupdate how can I do this?

    thanks..

    Please be more examplish when explaning I'm a new bie..

    Linux Mint 20.04 64 Bit QT6.0.1

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bsomervi
      wrote on last edited by bsomervi
      #2

      That should already be taken care of by the model. See http://doc.qt.io/qt-5/qsqltablemodel.html#setEditStrategy. If you setEditstrategy to OnManualSubmit you can choose when to save the new row to the database.

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

        Would enforcing rules in your database using triggers not help you here?

        If you want to enforce your business rules in the model, you could subclass QSqlTableModel and re-implement the submit() method.

        Or, change the model's EditStrategy to OnManualSubmit, create a 'Save' button and check the validity of the data in the button handler before calling the model's submitAll() method.

        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