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. Remove row from QSqlTableModel
QtWS25 Last Chance

Remove row from QSqlTableModel

Scheduled Pinned Locked Moved Unsolved General and Desktop
qsqltablemodeldelete row
7 Posts 3 Posters 3.4k 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.
  • S Offline
    S Offline
    sachi
    wrote on 14 Jan 2016, 17:41 last edited by
    #1

    Hi, I have created a QSqlTableModel with edit strategy is onManualSubmit. Now i want to delete a row from the table. deleted row is not completely removed until i submit the changes. Is there is a any way to remove row instantly from the model but not from the database?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 14 Jan 2016, 22:53 last edited by
      #2

      Hi,

      Something's not clear, why do you want to remove the row only from the model and not from the database ?

      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
      • S Offline
        S Offline
        sachi
        wrote on 15 Jan 2016, 11:32 last edited by
        #3

        Hi. I want it remove from database if I submit the changes. But now it doesn't remove from the tableview. It shows marked as remove. I want to remove row instantly when removeRow() is executed and only remove row from the database i clicked the submit.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mjsurette
          wrote on 15 Jan 2016, 11:52 last edited by
          #4

          You may want to look into the QSortFilterProxyModel class. It is able to filter out any records you like based on criteria you specify. They remain in the source model but aren't displayed by your view.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sachi
            wrote on 15 Jan 2016, 16:14 last edited by
            #5

            Is there a way to filter rows marked as deleted? i couldn't find a way.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 15 Jan 2016, 22:27 last edited by
              #6

              Since you know the row you want to delete you could use setRowHidden for that.

              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
              • S Offline
                S Offline
                sachi
                wrote on 18 Jan 2016, 17:50 last edited by
                #7

                Sorry for the late reply. Hidden row is not working because i want to remove row when user click over that row. I did is using TableView's on_table_clicked slot. if i hidden row from model tableView's index and model's index are not going to match. Is there any other solution?

                1 Reply Last reply
                0

                6/7

                15 Jan 2016, 22:27

                • Login

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