How to set font to bold/not-bold when clicking on a row in QTableView?

G Connor neothreeeight at hotmail.com
Wed Oct 26 23:25:21 BST 2022


PyQt5

With a QTableWidget it can be done like this:

font = QFont()
font.setBold(True) or False
for col in range(3,7):
    QTableWidget.item(row,col).setFont(font)

I looked online but couldn't find how to do it for QTableView.

Tried:
font = QFont()
font.setBold(True) or False
model = QTableView.model()
for col in range(3,7):
    model.setFont(model.index(row,col), font)

Throws AttributeError: 'QSqlTableModel' object has no attribute 'setFont'


Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20221026/a0a967c1/attachment.htm>


More information about the PyQt mailing list