Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-70599

QTableWidget repainting broken for 5.10 and 5.11 on macOS

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • None
    • 5.10.1, 5.11.0, 5.11.1
    • None
    • I am on macOS 10.13.
    • macOS

    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.

      Attachments

        1. TableUpdate.zip
          2 kB
        2. fcap1.png
          fcap1.png
          54 kB
        3. fcap2.png
          fcap2.png
          30 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            oryxdigital Andy Brice
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes