Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable edit-mode on a specific cell in a QTableWidget?

I can go to a specific cell:

ui->tableWidget->setCurrentCell(ui->tableWidget->rowCount() - 1, 0);

But how do I put the cell into editor mode, so the user does not have to double click the cell to begin editing the contents?

like image 613
gornvix Avatar asked Jan 29 '26 09:01

gornvix


1 Answers

The QTableWidget class inherits QAbstractItemView, which has the required APIs.

You just need to get the relevant model index using currentIndex(), and then pass that to the edit() slot to put the current cell into edit-mode:

ui->tableWidget->edit(ui->tableWidget->currentIndex());
like image 150
ekhumoro Avatar answered Jan 31 '26 08:01

ekhumoro