I'm using Python and PyQt and I have created a QTableWidget which I populate with data. Is there a way to search for a specific value and if the program finds something, can it hightlight the rows ?
Asked
Active
Viewed 2,596 times
1 Answers
1
Use list-of-QTableWidgetItem QTableWidget.findItems (self, QString text, Qt.MatchFlags flags)
to find your specific items.
http://pyqt.sourceforge.net/Docs/PyQt4/qtablewidget.html#findItems
After this iterate throw this list and use QTableWidgetItem.setBackgroundColor (self, QColor color)
for example to highlight this item
http://pyqt.sourceforge.net/Docs/PyQt4/qtablewidgetitem.html#setBackgroundColor
To highlight whole row you can use setBackgroundColor
for every item in the table(with given row) or if you want to select rows, you can use this or just selectRow()
http://pyqt.sourceforge.net/Docs/PyQt4/qtableview.html#selectRow