2016-06-16 29 views
0

我有QT TableWidget,我想根据它们的值更改列的背景颜色。看来我可以改变所有列的背景做这样的事情:QT TableWidget头部更改给出列背景颜色

tableWidget->horizontalHeader()->setStyleSheet("QHeaderView::section {background-color: red}");

但我想改变颜色,给定列和每一列的颜色可以不同。任何人都做过这样的事情?

+0

这可能有所帮助:http://stackoverflow.com/questions/30847252/what-does-qheaderviewpaintsection-do-such-that-all-i-do-to-the-painter-before – AlexanderVX

回答

0

你可以考虑使用QTableView和Qt Model/View框架来做到这一点。