Hello,
I'm trying to multiply the Quantity*Price for each row then add them all up to get the total value of all the items I have.
This is what I have so far:
Thanks in advance.
I'm trying to multiply the Quantity*Price for each row then add them all up to get the total value of all the items I have.
This is what I have so far:
def calculate_value(self):
for row in range(self.InventoryDisplay.model().rowCount()):
QuantityValue = float(self.InventoryDisplay.model().index(row, 2).data())
PriceValue = float(self.InventoryDisplay.model().index(row, 3).data())
QuanityPriceValue = QuantityValue*PriceValue
print(QuanityPriceValue)My output:Output:89.0
0.0
75.0
200.0
32.5
20.0
20.0
4000.0
100.0The part I'm having trouble with is how do I add all my QuanityPriceValue's that were spit out from that for loop so I can get the combined total (In this case it should be: 4,516.5)?Thanks in advance.
