O
O
Oleg Seledets2019-01-06 14:59:47
Qt Creator
Oleg Seledets, 2019-01-06 14:59:47

How to remove from tableWidget on double click?

Hello, you need to double-click on an entry to delete it from tableWidget
, there is such a piece of code:

void reportHelp::on_tableWidget_itemDoubleClicked(QTableWidgetItem *item)
{
    int i= ui->tableWidget->selectionModel()->selectedRows().count();
    ui->tableWidget->removeRow(i);
}

It deletes any record except the first table. What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2019-01-06
@oleja1ee7

If I understood correctly

you need to double-click on the entry to remove it from the tableWidget

int i = ui->tableWidget->selectionModel()->currentIndex().row();
ui->tableWidget->removeRow(i);

doc.qt.io/qt-5/qitemselectionmodel.html#currentIndex

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question