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 to delete a entire by selecting particular row from QTableview using push button and table is connected with database

How to delete a entire by selecting particular row from QTableview using push button and table is connected with database

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 2.5k 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.
  • V Offline
    V Offline
    veera
    wrote on last edited by
    #1

    How to delete a entire by selecting particular row from QTableview using push button and table is connected with database

    K 1 Reply Last reply
    0
    • V veera

      How to delete a entire by selecting particular row from QTableview using push button and table is connected with database

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @veera

      You might consider using QTableWidget which inherits from QTableView. There you can remove rows

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • V Offline
        V Offline
        veera
        wrote on last edited by
        #3

        i am familiar with tableview and it is very easy to do inserting and updating data from the database so......using tableview we can't delete it?

        K 1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by VRonin
          #4

          duplicate of https://forum.qt.io/topic/23600/qtableview-remove-selected-rows/6

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          1
          • V veera

            i am familiar with tableview and it is very easy to do inserting and updating data from the database so......using tableview we can't delete it?

            K Offline
            K Offline
            koahnig
            wrote on last edited by
            #5

            @veera said in How to delete a entire by selecting particular row from QTableview using push button and table is connected with database:

            i am familiar with tableview and it is very easy to do inserting and updating data from the database so......using tableview we can't delete it?

            There are probably good reasons that there is no delete command in table view. My personal guess is the view part of the name.

            I suggest that you make yourself a bit more familiar with C++ and the meaning of inheritance especially. In the nutshell it means that the functionality is mostly available in the class inheriting from another.

            Most likely you can use QTableWidget instead of QTableView in your apps.

            Also as @VRonin already marked you are repeating topics and questions, which is typically not appreciated by all members of the forum.

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            2
            • V Offline
              V Offline
              veera
              wrote on last edited by
              #6

              Hi all,
              by passing id of tableview from line edit and execute query ,we can delete the entire row easily but selecting row and delete pushbutton is not happening is there any specific reason explain me plz.....

              VRoninV 1 Reply Last reply
              0
              • V veera

                Hi all,
                by passing id of tableview from line edit and execute query ,we can delete the entire row easily but selecting row and delete pushbutton is not happening is there any specific reason explain me plz.....

                VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by
                #7

                @veera said in How to delete a entire by selecting particular row from QTableview using push button and table is connected with database:

                by passing id of tableview from line edit and execute query ,we can delete the entire row easily

                Let's start from here. can you show us this code?

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  veera
                  wrote on last edited by veera
                  #8

                  calculating the index of particular row of tableview by executing these two queries it was solved....
                  QModelIndexList ids = ui->tableView->selectionModel()->selectedRows();
                  //QString val = ui->lineEdit_5->setText(model->index(ids,0).data().toString());
                  QString rowdata1;
                  //rowdata1 = ui->tableView->model()->data(ui->tableView->model()->index(ids,0)).toString();
                  rowdata1 = ui->tableView->model()->data(ui->tableView->model()->index(rowdx,0)).toString();

                  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