在 qtablewidget 顶部插入行

Insert row on top of a qtablewidget

我想知道是否可以在 qtablewidget 上插入一行? 类似于:

ui->myqtablewidget->insertRow(0);

Just a heads up - I'm answered based on the documentation and C++ knowledge, not direct experience with Qt.

QTableWidget 似乎有一个 insertRow() 功能。您只需指定要放置行的位置。 Read the documentation here

因此,从文档中可以看出,您可以在 table 的开头 ("top") 插入一行代码...

ui->myqtablewidget->insertRow(0);

...假设 uimyqtablewidget 已正确声明。