<?php
require("w.php");
require("IQuiP/QApplication.php");
$app = new QApplication;
if(!RESTORED) $window = new w($app); // if(!RESTORED) is currently needed when creating the main window... this should go away soon.
$app->exec();
?>
<?php
require("w.php");
require("IQuiP/QApplication.php");
$app = new QApplication;
if(!RESTORED) $window = new w($app); // if(!RESTORED) is currently needed when creating the main window... this should go away soon.
$app->exec();
?>
To copy to clipboard, switch view to plain text mode
<?php
include('IGPL/IQuiP/QMainWindow.php');
include('IGPL/IQuiP/QPushButton.php');
include('IGPL/IQuiP/QLabel.php');
class w extends QMainWindow { // Creates the main applicatiton window
private $numberLabel; // Initialize the number label
private $count=0; // Initialize the counter to 0
private $incrementButton; // Initialize the Increment button
private $decrementButton; // Initialize the Decrement button
private $colorButton; // Initialize button to change the color
private $textColor;
public function __construct(&$parent=NULL) { // This block runs when the main window is created
parent::__construct($parent); // Sets the parent of this object
$this->setWindowTitle('A taste of IQuiP'); // Sets the title of this window
$this->numberLabel = new QLabel($this->count,$this); // Creates the number label
$this->incrementButton = new QPushButton('Increment',$this); // Creates the Increment button
$this->decrementButton = new QPushButton('Decrement',$this); // Creates the Decrement button
$this->colorButton = new QPushButton('Turn Text Red',$this); // Creates the blue button
$this->textColor = 'black';
$this->connect($this->incrementButton,'clicked()',$this,'increment()'); // What to do if Increment is clicked
$this->connect($this->decrementButton,'clicked()',$this,'decrement()'); // What to do if Decrement is clicked
$this->connect($this->colorButton,'clicked()',$this,'changeColor()');
$this->connect($this,'updateNumber()',$this->numberLabel,'setText()');
$this->connect($this,'updateButton()',$this->colorButton,'setText()');
$this->connect($this,'updateColor()',$this->numberLabel,'setColor()');
}
public function increment() { // This block runs when the user clicks Increment
$this->count++; // Increment the counter by one
$this->emit('updateNumber('.$this->count.')'); // Create an update signal
}
public function decrement() { // This block runs when the user clicks Decrement
$this->count--; // Decrement the counter by one
$this->emit('updateNumber('.$this->count.')'); // Create an update signal
}
public function changeColor() {
switch($this->textColor) {
case 'black':
$this->emit('updateButton(Turn Text Blue)');
$this->textColor='red';
break;
case 'red':
$this->emit('updateButton(Turn Text Pink)');
$this->textColor='blue';
break;
case 'blue':
$this->emit('updateButton(Turn Text Purple)');
$this->textColor='pink';
break;
case 'pink':
$this->emit('updateButton(Turn Text Orange)');
$this->textColor='purple';
break;
case 'purple':
$this->emit('updateButton(Turn Text Black)');
$this->textColor='orange';
break;
case 'orange':
$this->emit('updateButton(Turn Text Red)');
$this->textColor='black';
break;
}
$this->emit("updateColor({$this->textColor})");
}
}
?>
<?php
include('IGPL/IQuiP/QMainWindow.php');
include('IGPL/IQuiP/QPushButton.php');
include('IGPL/IQuiP/QLabel.php');
class w extends QMainWindow { // Creates the main applicatiton window
private $numberLabel; // Initialize the number label
private $count=0; // Initialize the counter to 0
private $incrementButton; // Initialize the Increment button
private $decrementButton; // Initialize the Decrement button
private $colorButton; // Initialize button to change the color
private $textColor;
public function __construct(&$parent=NULL) { // This block runs when the main window is created
parent::__construct($parent); // Sets the parent of this object
$this->setWindowTitle('A taste of IQuiP'); // Sets the title of this window
$this->numberLabel = new QLabel($this->count,$this); // Creates the number label
$this->incrementButton = new QPushButton('Increment',$this); // Creates the Increment button
$this->decrementButton = new QPushButton('Decrement',$this); // Creates the Decrement button
$this->colorButton = new QPushButton('Turn Text Red',$this); // Creates the blue button
$this->textColor = 'black';
$this->connect($this->incrementButton,'clicked()',$this,'increment()'); // What to do if Increment is clicked
$this->connect($this->decrementButton,'clicked()',$this,'decrement()'); // What to do if Decrement is clicked
$this->connect($this->colorButton,'clicked()',$this,'changeColor()');
$this->connect($this,'updateNumber()',$this->numberLabel,'setText()');
$this->connect($this,'updateButton()',$this->colorButton,'setText()');
$this->connect($this,'updateColor()',$this->numberLabel,'setColor()');
}
public function increment() { // This block runs when the user clicks Increment
$this->count++; // Increment the counter by one
$this->emit('updateNumber('.$this->count.')'); // Create an update signal
}
public function decrement() { // This block runs when the user clicks Decrement
$this->count--; // Decrement the counter by one
$this->emit('updateNumber('.$this->count.')'); // Create an update signal
}
public function changeColor() {
switch($this->textColor) {
case 'black':
$this->emit('updateButton(Turn Text Blue)');
$this->textColor='red';
break;
case 'red':
$this->emit('updateButton(Turn Text Pink)');
$this->textColor='blue';
break;
case 'blue':
$this->emit('updateButton(Turn Text Purple)');
$this->textColor='pink';
break;
case 'pink':
$this->emit('updateButton(Turn Text Orange)');
$this->textColor='purple';
break;
case 'purple':
$this->emit('updateButton(Turn Text Black)');
$this->textColor='orange';
break;
case 'orange':
$this->emit('updateButton(Turn Text Red)');
$this->textColor='black';
break;
}
$this->emit("updateColor({$this->textColor})");
}
}
?>
To copy to clipboard, switch view to plain text mode
Bookmarks