Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTableWidget repainting broken on 5.10 and 5.11 on macOS
Qt 6.11 is out! See what's new in the release blog

QTableWidget repainting broken on 5.10 and 5.11 on macOS

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • AndyBriceA Offline
    AndyBriceA Offline
    AndyBrice
    wrote on last edited by
    #1

    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:

    0_1537279648276_fcap1.png

    Adding empty rows doesn't repaint the vertical header:

    0_1537279664334_fcap2.png

    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.

    Main source 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();
    }
    

    This 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.

    I am on macOS 10.13.

    With the other Qt bugs I have come across, I am having a great deal of difficulty finding a recent version of Qt for Mac that doesn't have a showstopper bug!
    https://forum.qt.io/topic/94535/qfontdialog-broken-in-5-11-1-on-mac/
    https://forum.qt.io/topic/91642/qstatictext-size-bug-when-using-rich-text-and-word-wrap/

    --
    Andy Brice
    https://www.perfecttableplan.com

    AndyBriceA 1 Reply Last reply
    0
    • AndyBriceA AndyBrice

      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:

      0_1537279648276_fcap1.png

      Adding empty rows doesn't repaint the vertical header:

      0_1537279664334_fcap2.png

      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.

      Main source 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();
      }
      

      This 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.

      I am on macOS 10.13.

      With the other Qt bugs I have come across, I am having a great deal of difficulty finding a recent version of Qt for Mac that doesn't have a showstopper bug!
      https://forum.qt.io/topic/94535/qfontdialog-broken-in-5-11-1-on-mac/
      https://forum.qt.io/topic/91642/qstatictext-size-bug-when-using-rich-text-and-word-wrap/

      --
      Andy Brice
      https://www.perfecttableplan.com

      AndyBriceA Offline
      AndyBriceA Offline
      AndyBrice
      wrote on last edited by
      #2

      Has anyone else seen this behaviour? Is there a workaround, other than calling viewport()->repaint() all over the place?

      --
      Andy Brice
      https://www.perfecttableplan.com

      AndyBriceA 1 Reply Last reply
      0
      • AndyBriceA AndyBrice

        Has anyone else seen this behaviour? Is there a workaround, other than calling viewport()->repaint() all over the place?

        --
        Andy Brice
        https://www.perfecttableplan.com

        AndyBriceA Offline
        AndyBriceA Offline
        AndyBrice
        wrote on last edited by
        #3

        Weirdly, I can't find any other reports of this bug, so I filed a bug report:
        https://bugreports.qt.io/browse/QTBUG-70599

        Andy Brice
        https://www.perfecttableplan.com

        1 Reply Last reply
        1
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #4

          Hi, just want to confirm your bug (tested on my Mac).

          Have some Qt apps on Windows which are heavily users of QTableWidget, also filed some bugs (most recent this one)

          If you change your QStringList stuffing line to say:
          values << "combo1" << "combo2" << "supercalifragilisticexpialidocious";
          you can see my bug in action (if you're on 5.11).

          AndyBriceA 1 Reply Last reply
          0
          • hskoglundH hskoglund

            Hi, just want to confirm your bug (tested on my Mac).

            Have some Qt apps on Windows which are heavily users of QTableWidget, also filed some bugs (most recent this one)

            If you change your QStringList stuffing line to say:
            values << "combo1" << "combo2" << "supercalifragilisticexpialidocious";
            you can see my bug in action (if you're on 5.11).

            AndyBriceA Offline
            AndyBriceA Offline
            AndyBrice
            wrote on last edited by AndyBrice
            #5

            @hskoglund I confirm that I can reproduce your problem.

            0_1537286506446_fcap3.png

            And it isn't fixed by a repaint.

            QFontDialog is also totally broken on Qt 5.11.1 and the 5.11.2 snapshot. These regressions in core parts of Qt are very frustrating. The macOS version seems particularly prone to them. The Windows version seems pretty solid.

            --
            Andy Brice
            https://www.perfecttableplan.com

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved