Go to the Total's field's properties, Calculate tab, and enter something like this:
event.value = (Number(this.getField("Quantity1").value) * Number(this.getField("Price1").value)) + (Number(this.getField("Quantity2").value) * Number(this.getField("Price2").value)) + (etc.)
Of course, you'll need to adjust the field names to match those in your file. The calculation will update each time you update the value of one of the fields (when you exit that field, not as you're typing it!).
In order to prevent the calculation of no quantities are entered, you'll have to test the values to see if any are not zero and proceed with the calculation in any are not. If all are zero, set event.value to 0.
There's no need to do that because Number("") returns 0.
For each row you can use the calculation option "Field is the product of fields:" to compute the row product.
For the total of the extended quantity x price you can use the "Field is the sum of fields".
Fore each calculated field you can use the following "Validation" script:
if(event.value == 0) event.value = "";
For the above to take effect you will either need to clear the form or perform a calculation.
You may also need to adjust the calculation order of the form fields.