我想风格的Qt样式表一个QTableView中。一切工作正常,但只要选择表视图数据的所有表头文本(列标题)绘制为粗体。
我已经试过这样的事情:
QTableView::section {
font-weight: 400;
}
QTableView::section:selected {
font-weight: 400;
}
QHeaderView {
font-weight: 400;
}
QHeaderView::section {
font-weight: 400;
}
无济于事。
任何人都可以点我在正确的方向,最好使用样式表?
我没有测试过,但QHeaderView::highlightSections属性设置为false应该做的伎俩。
您可以使用QTableView中的verticalHeader()
和horizontalHeader()
方法获得一个指向QHeaderView对象。
在Qt设计UI格式,你可以使用属性horizontalHeaderHighlightSections
:
<widget class="QTableView" name="m_studyList">
<attribute name="horizontalHeaderHighlightSections">
<bool>false</bool>
</attribute>
但它也完全禁用所选列CSS。