Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[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?

    @QTableWidget* tableWidget = new QTableWidget( parent );
    tableWidget->setRowCount( 8 );
    tableWidget->setColumnCount( 10 );

    QColor color( Qt::red );
    tableWidget->item( 0, 0 )->setBackgroundColor( color );@



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


Log in to reply