Qt: QTableView, how to add a row?

I have a QTableView with data in it. What is the easiest way to add a string?

Thanks!

+4
source share
2 answers

QTableView is model-based, if you don’t know which model, then I suggest you read here .

Using a QTableWidget instead is a lot easier for beginners, and you can add a row just like this.

ui->tableWidget->insertRow(0); 
+2
source

As you use som YourModel to show it in YourTableView (QTableView), follow these steps:

 YourModel->insertRow(YourModel->rowCount(QModelIndex())); // paste some data to new row 

Updating a model causes a view update.

+3
source

Source: https://habr.com/ru/post/1442696/


All Articles