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. Esc key pressed on new row in edit mode deletes the row from view, but still triggers submit to database

Esc key pressed on new row in edit mode deletes the row from view, but still triggers submit to database

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 465 Views 1 Watching
  • 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.
  • C Offline
    C Offline
    CelsoSantos65
    wrote on last edited by
    #1

    Hi, I'm trying to use a QSqlTableModel whose edit strategy is set as OnRowChange. After creating a new row and start editing it in the view, I fill in the first record and press TAB to edit next record. At this point, if I press the ESC key the row disappears from the view, but somehow the engine still triggers the submit() slot in the model and the incomplete row is submitted to the database. I think that the row vanishing from the view is coherent with pressing an escape key, but in this case the model submit slot should not be called. Is there a way to fix this? Thanks!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You should change to manual submit to handle your use case.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • C Offline
        C Offline
        CelsoSantos65
        wrote on last edited by
        #3

        Thanks for the welcome and for the hint. In this case the easiest manual submit solution would be to place a 'submit' button for the user to click. I was thinking of a more 'automated' solution, but I guess I will have to place an event handler somewhere to detect navigation/enter/esc/row change events....Any hint on the best way to do that? Thanks

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          What about calling revert when escape is used ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          C 1 Reply Last reply
          1
          • SGaistS SGaist

            What about calling revert when escape is used ?

            C Offline
            C Offline
            CelsoSantos65
            wrote on last edited by
            #5

            @SGaist I'll try doing that. The ESC capture must be done inside the editor used to enter new data, so I'll probably have to install the event filter in the delegate used to generate the editor. I'll see what I can do and post the results later.

            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