To change the border itself you'll probably need to create a custom delegate that does something along these lines:
class MyDelegate : public QItemDelegate {
public:
MyDelegate( QObject *parent ) : QItemDelegate( parent ) { }
void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const {
QItemDelegate::paint( painter, option, index );
if( /* some condition */ ) {
painter->setPen( Qt::red );
painter->drawRect( option.rect );
}
}
}
Then you can call:
myTableWidget->setItemDelegate( new MyDelegate(this) );
You can use QTableWidgetItem::setData()
and the QModelIndex::data()
functions to pass the necessary information back and forth between your table and the delegate
See the qt documentation for QItemDelegate
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…