This problem is driving me nuts, and it's happened in several of my applications. I think I wrote this to qt-interest but a search there says otherwise. I found this thread in my searching, which didn't exactly help but it sounds similar. Mine is a bit weirder though.

The problem is my QTableWidget's top row will not update until a user-driven event. I'm explicitely calling update() every time I add a row or change the contents of a QTableWidgeteItem. For safe mesure I even added QTimer that calles update() every 500 milliseconds. It will not update. The kicker is, it's the top row only, and I've seen it in a few projects.

I'm not setting setUpdatesEnabled( false ). The widget is definitely not hidden.

The project is too big to post, but the idea is below. There's really no "magic" going on anywhere (that I know of). One really ghetto way I got around it in one application was to make a "dummy row" that had enough height to take the brunt of the non-repainting. The only way I can get it to repaint is some type of user input. Resize the entire dialog, Click & Drag the mouse over each column of row 0, etc.

Qt Code:
  1. mytable::mytable( int r, int c, QWidget* parent ) : QTableWidget( r, c, parent )
  2. {
  3. QStringList headers;
  4. headers >> "h1" << "h2"; //etc
  5. setHorizontalHeaderLabels( headers );
  6. setShowGrid( false );
  7. setFocusPolicy( Qt::NoFocus );
  8. setSelectionMode( QAbstractItemView::NoSelection );
  9. setEditTriggers( QAbstractItemView::NoEditTriggers );
  10. verticalHeader()->hide();
  11. verticalHeader()->setDefaultSectionSize( fontMetrics().lineSpacing() + 2 );
  12. // hide the last column
  13. horizontalHeader()->hideSection( columnCount() - 1 );
  14. }
  15.  
  16. myview::myview( QWidget* parent ) : QDialog( parent )
  17. {
  18. mytable* table = new mytable( 0, 10, this );
  19. mytable->setStyle( new QPlastiqueStyle ); // oxygen table is crap
  20. }
  21.  
  22. int main( int argc, char* argv[] )
  23. {
  24. QApplication app( argc, argv );
  25. myview* view = new myview();
  26. view->show();
  27. return app.exec();
  28. }
To copy to clipboard, switch view to plain text mode 

As per before, nothing too crazy. For now, this really, really tacky fix works. I call it whenever I do anything to row 0.

Qt Code:
  1. void mytable::crap_paint_hack()
  2. {
  3. insertRow( 0 );
  4. removeRow( 0 );
  5. }
To copy to clipboard, switch view to plain text mode