![]() |
[PyQt]Find item or text in Qtablewidget - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [PyQt]Find item or text in Qtablewidget (/thread-12042.html) |
[PyQt]Find item or text in Qtablewidget - maziio - Aug-06-2018 Hi, I need help with this : def change(self): def change(self): m = 2 cur = conn.cursor() conn.text_factory = str cur.execute(" SELECT quranuthmani FROM Translation WHERE sura = ?", (m,)) all_rows = cur.fetchall() a = 0 self.SearchResult.setRowCount(286) for row in all_rows: Scontent = QtWidgets.QTableWidgetItem() Scontent.setText("{}".format(row[0])) self.SearchResult.setItem(a ,0,Scontent) a = a + 1 self.SearchResult.resizeRowsToContents() def find_items(self): items = self.SearchResult.findItems(self.lineEdit.text(),QtCore.Qt.MatchContains) brush = QtGui.QBrush(QtGui.QColor("orange")) brush.setStyle(QtCore.Qt.SolidPattern) for item in items: item.setForeground(brush)Search result is a qtable widget and the data is text so: I want to select the exact text that I put in lineEdit and mark it or highlight it but the above code select all the cell. |