I have a QTableWidget with 10 rows and 11 columns. Here is some of the initialization:
Qt Code:
  1. logTable = new QTableWidget(10, 11, this);
  2. logTable->setSelectionMode(QAbstractItemView::SingleSelection);
  3. logTable->setSelectionBehavior(QAbstractItemView::SelectRows);
  4. connect(logTable, SIGNAL(itemSelectionChanged()), this, SLOT(tableSelectionChanged()));
To copy to clipboard, switch view to plain text mode 
About half of the table cells are filled with QTableWidgetItems and the other half is QLabels. When a user selects a row in the table, the QLabels don't change, so that's why I made the tableSelectionChanged() slot. Inside that slot, I change the stylesheets of all the QLabels, and things work just fine. With the QTableWidgetItems, however, I can't change their appearance inside the slot (the default appearance takes precedence). I use the setBackgroundColor method in the slot to change the QTableWidgetItem background, but it has no effect. Also, the font color in the QTableWidgetItems changes from black to white, which I don't want. How can I disable the default behavior of the QTableWidgetItems, so I can replace it with my own?