QTableWidget内容不刷新
解决方法
使用如下代码:
ui->tableWidget->viewport()->update();
原因
update()是更新这个控件
viewport()->update()是更新这个控件里面的内容
进一步分析
QTableWidget Class 官网的资料如下
http://doc.qt.io/qt-5/qtablewidget.html
顺着继承关系,一步步往上找,会发现如下说明
Note: If you inherit QAbstractItemView and intend to update the contents of the viewport, you should use viewport->update() instead of update() as all painting operations take place on the viewport.

浙公网安备 33010602011771号