I'm trying to do a GUI that can calculate multiple vectors operations (sum, rest, multiplication, division). I'm using the "QTableWidget" from "Qt Designer" and doing the code in spyder. But I can't find the way to perform the operations, I'm new using "Qt Designer".
I already got it to do the sums of the values, but now I have another problem, how could I sum the value of each column more efficiently?, since in this way I would have a very long code
def Defin(self):
nv = self.spinBox.value()
tv = self.spinBox_2.value()
self.tableWidget.setColumnCount(tv)
self.tableWidget.setRowCount(nv)
self.tableWidget_3.setColumnCount(tv)
self.tableWidget_3.setRowCount(1)
self.tableWidget.setVerticalHeaderLabels(str("Vector 1;Vector 2;Vector 3;Vector 4;Vector 5;Vector 6;Vector 7;Vector 8;Vector 9;Vector 10",).split(";"))
self.tableWidget_3.setVerticalHeaderLabels(str("Vector Resultante;",).split(";"))
def Operacion(self):
cb = self.comboBox.currentText()
if (cb=="Suma"):
v1= self.tableWidget.item(0,0)
v2= self.tableWidget.item(1,0)
v1= v1.text()
v2= v2.text()
vri= int(v1) + int(v2)
vri= str(vri)
vri= QTableWidgetItem(vri)
v3= self.tableWidget.item(0,1)
v4= self.tableWidget.item(1,1)
v3= v3.text()
v4= v4.text()
vri2= int(v3) + int(v4)
vri2= str(vri2)
vri2= QTableWidgetItem(vri2)
self.tableWidget_3.setItem(0, 0, vri)
self.tableWidget_3.setItem(0, 1, vri2)