Reusing a class function for QTableWidget – PyQt5

  class, function, pyqt5, python

I’ve here this function named search inside my class:

def search_prototype1(self, word, column):
    for rowIndex in range(self.tableWidget.rowCount()):
        item = self.tableWidget.item(rowIndex, column)
        if item is not None:
            if word in item.text():
                self.tableWidget.setCurrentCell(rowIndex, 2)

What this function does is to search a certain column in a Table widget and highlight it.

But Since I need to use it for multiple QTableWidget, My Question is: How can I make this function reusable so I can use it in multiple QTableWidget?

I wish someone can help me

Source: Python Questions

LEAVE A COMMENT