Feb-20-2020, 08:58 PM
hi;
I have many object of QTabelwidget (tablewidget1,tablewidgte2,tablewidget3, ...)
I created a function for each tablewidget, therefore I have a number of functions equal to the number of tablewidget.
I wonder how to create a single function which will replace all these functions by changing only the argument which will coincide with the name of the tablewidget
I try this function instead of the initial function but doesn't work like I want
I have many object of QTabelwidget (tablewidget1,tablewidgte2,tablewidget3, ...)
I created a function for each tablewidget, therefore I have a number of functions equal to the number of tablewidget.
def intialiser_tableWidget(self): self.tableWidget.clear() # effacer contenu self.tableWidget.setHorizontalHeaderItem(0, QTableWidgetItem("date")) self.tableWidget.setHorizontalHeaderItem(1, QTableWidgetItem("hour")) self.tableWidget.setHorizontalHeaderItem(2, QTableWidgetItem("Mo1")) self.tableWidget.setHorizontalHeaderItem(3, QTableWidgetItem("Mon2"))this function is activated by clicking on a radiobutton.
I wonder how to create a single function which will replace all these functions by changing only the argument which will coincide with the name of the tablewidget
I try this function instead of the initial function but doesn't work like I want
arg=QTableWidget def intialiser_tableWidget_correction(self,arg): self.arg.clear() self.arg.setHorizontalHeaderItem(0, QTableWidgetItem("date")) self.arg.setHorizontalHeaderItem(1, QTableWidgetItem("hour")) self.arg.setHorizontalHeaderItem(2, QTableWidgetItem("Mon1")) self.arg.setHorizontalHeaderItem(3, QTableWidgetItem("Mon2"))