October 11, 2010

Sorin Sorin
Lab Rat
42 posts

[Solved]Color a QTableWidget cell

 

I’m trying to color a cell from a QTableWidget but it seams that I’m doing something wrong because is not working( fails silently ), what is my mistake?

  1. QTableWidget* tableWidget = new QTableWidget( parent );
  2. tableWidget->setRowCount( 8 );
  3. tableWidget->setColumnCount( 10 );
  4.  
  5. QColor color( Qt::red );
  6. tableWidget->item( 0, 0 )->setBackgroundColor( color );

 Signature 

There are only 10 types of people in the world: Those who understand binary, and those who don’t

1 reply

October 11, 2010

Sorin Sorin
Lab Rat
42 posts

Found the problem, it was needed to cal tableWidget->setItem( 0,0, tableItem ) to add an item to tableWidget

 Signature 

There are only 10 types of people in the world: Those who understand binary, and those who don’t

 
  ‹‹ [Solved] overloading dropEvent      selecting data from mysql using qt? ››

You must log in to post a reply. Not a member yet? Register here!