Python Forum

Full Version: [PyQt]Find item or text in Qtablewidget
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.