4. Basic QForms
Calculator Example
<< Understanding Process Flow
|
Back to Main
|
Calculator Example with Validation >>
View Source
will open in a new window
The Four-Function Calculator: Our First Simple Application
We can combine this understanding of statefulness and events to make our first simple Qforms application.
This calculator is just a collection of two
QTextBox
objects (one for each operand), a
QListBox
object containing the four arithmetic functions, a
QButton
object to execute the operation, and a
QLabel
to view the result. Note that there is no validation, checking, etc. currently in the Qform. Any string data will be parsed by PHP to see if there is any numeric data, and if not, it will be parsed as 0. Dividing by zero will throw a PHP error.
Value 1:
Value 2:
Operation:
+
-
*
/
Calculate