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


  • Moderators

    @veera

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



  • 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?




  • Moderators

    @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.



  • 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.....



  • @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?



  • 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();


Log in to reply