Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
None
-
5.10.1, 5.11.0, 5.11.1
-
None
-
I am on macOS 10.13.
Description
QTableWidget does not repaint correctly for operations such as adding rows. The problems seems to be particularly bad if QWidgets are shown in cells.
Adding rows with combo widgets doesn't repaint most of the table:
Adding empty rows doesn't repaint the vertical header:
If you resize the window or force a QTableWidget viewport()->repaint() after adding the rows, it updates correctly. But it is pretty klunky to force a repaint after each operation.
Source for the above example application is attached in a zip. The main part is here:
#include "MainWindow.h" #include <QComboBox> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setupUi(this); m_tableWidget->setColumnCount( 4 ); m_tableWidget->setRowCount( 0 ); connect( m_addWithButton, SIGNAL( clicked() ), this, SLOT( onAddWith() ) ); connect( m_addWithoutButton, SIGNAL( clicked() ), this, SLOT( onAddWithout() ) ); connect( m_clearButton, SIGNAL( clicked() ), this, SLOT( onClear() ) ); } void MainWindow::onAddWith() { m_tableWidget->setRowCount( m_tableWidget->rowCount() + 1 ); for ( int c = 1; c < 3; c++ ) { QComboBox* comboItem = new QComboBox( m_tableWidget ); QStringList values; values << "combo1" << "combo2"; comboItem->addItems( values ); m_tableWidget->setCellWidget( m_tableWidget->rowCount() - 1, c, comboItem ); } if ( m_repaintCheckBox->isChecked() ) m_tableWidget->viewport()->repaint(); } void MainWindow::onAddWithout() { m_tableWidget->setRowCount( m_tableWidget->rowCount() + 1 ); if ( m_repaintCheckBox->isChecked() ) m_tableWidget->viewport()->repaint(); } void MainWindow::onClear() { m_tableWidget->setRowCount( 0 ); if ( m_repaintCheckBox->isChecked() ) m_tableWidget->viewport()->repaint(); }
QTableWidget painting is broken on Qt 5.10.1, 5.11.0, 5.11.1 and 5.11.2 snapshot (18-Sep) for macOS.
It works ok for Qt 5.9.6 for macOS and all Qt versions I tried for Windows.