Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt: QTableView how to add a row?

Tags:

qt

qtableview

I have got a QTableView with data in it. What is the simplest way to add a row?

Thanks!

like image 788
Michael Zelensky Avatar asked Oct 29 '12 08:10

Michael Zelensky


People also ask

What is the difference between QTableView and QTableWidget?

The major difference between the two is that QTableView requires you to use an external class derived from QAbstractItemModel with it. The rowCount(), columnCount(), and data() methods for the item model are used by the table view to tell it how to fill in and format the table cells.


1 Answers

As you use som YourModel to show it in YourTableView (QTableView) should do like this:

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

update of model causes update of View

like image 109
AlexBee Avatar answered Sep 28 '22 18:09

AlexBee