Python Forum
[PyQt]Find item or text in Qtablewidget
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt]Find item or text in Qtablewidget
#1
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] QTableWidget print problem JokerSob 8 4,799 Jan-28-2022, 06:08 PM
Last Post: Axel_Erfurt
  [PyQt] How do I display the DB table I will choose from the QComboBox in QTableWidget JokerSob 2 2,326 Aug-05-2021, 03:00 PM
Last Post: JokerSob
  Displaying database info in QTableWidget thewolf 6 5,297 Apr-03-2021, 02:49 PM
Last Post: thewolf
  [PyQt] Help: check content of combobox in horizontal header of QTableWidget mart79 1 3,375 Jul-26-2020, 06:18 PM
Last Post: deanhystad
  [PyQt] Add validation (regex) to QTableWidget cells mart79 0 2,757 May-05-2020, 12:51 PM
Last Post: mart79
  [PyQt] QTableWidget stylesheet error mart79 3 6,458 Feb-26-2020, 04:54 PM
Last Post: Denni
  [PyQt] Pyqt5: How do you make a button that adds new row with data to a Qtablewidget YoshikageKira 6 7,037 Jan-02-2020, 04:32 PM
Last Post: Denni
  Update value selected in option menu when select an item from text box klllmmm 2 5,037 Jun-06-2019, 04:51 AM
Last Post: klllmmm
  [PyQt] QTableWidget cell validation littleGreenDude 1 7,694 Jan-18-2019, 07:44 PM
Last Post: littleGreenDude
  Printing QTableWidget to an DIN A4 page Mady 2 7,241 Dec-18-2018, 06:56 PM
Last Post: Axel_Erfurt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020