I used QTableWidget in my program, and tried to set the background color of some certain cells, however every time i got nothing except Access violation.
QTableWidget* tTable = new QTableWidget();
tTable->setItem(0, 0, new QTableWidgetItem());
tTable->item(0, 0)->setBackgroundColor(Qt::red);
I’m using MSVC 2010.
Use
setRowCountandsetColumnCountin order to set the number of rows and columns for your table.Alternatively provide the number of rows and columns of the table in the constructor