Example #1
0
 public function __construct()
 {
     parent::__construct();
     $quit = new QPushButton(tr("&Quit"));
     $quit->setFont(new QFont("Times", 18, QFont::Bold));
     QObject::connect($quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()'));
     $angle = new LCDRange();
     $angle->setRange(5, 70);
     $force = new LCDRange();
     $force->setRange(10, 50);
     $cannonField = new CannonField();
     QObject::connect($angle, SIGNAL('valueChanged(int)'), $cannonField, SLOT('setAngle(int)'));
     QObject::connect($cannonField, SIGNAL('angleChanged(int)'), $angle, SLOT('setValue(int)'));
     QObject::connect($force, SIGNAL('valueChanged(int)'), $cannonField, SLOT('setForce(int)'));
     QObject::connect($cannonField, SIGNAL('forceChanged(int)'), $force, SLOT('setValue(int)'));
     $shoot = new QPushButton(tr("&Shoot"));
     $shoot->setFont(new QFont("Times", 18, QFont::Bold));
     QObject::connect($shoot, SIGNAL('clicked()'), $cannonField, SLOT('shoot()'));
     $topLayout = new QHBoxLayout();
     $topLayout->addWidget($shoot);
     $topLayout->addStretch(1);
     $leftLayout = new QVBoxLayout();
     $leftLayout->addWidget($angle);
     $leftLayout->addWidget($force);
     $gridLayout = new QGridLayout();
     $gridLayout->addWidget($quit, 0, 0);
     $gridLayout->addLayout($topLayout, 0, 1);
     $gridLayout->addLayout($leftLayout, 1, 0);
     $gridLayout->addWidget($cannonField, 1, 1, 2, 1);
     $gridLayout->setColumnStretch(1, 10);
     $this->setLayout($gridLayout);
     $angle->setValue(60);
     $force->setValue(25);
     $angle->setFocus();
 }
Example #2
0
 /**
  * test references					<br><br>
  * <code>
  * $a = new QPushButton("a text");			<br>
  * $b = &$a;						<br>
  * $a->setText("text changed");				<br>
  * $b->text()->__toString(); // "text changed"		<br>
  *</code>
  */
 function testReference()
 {
     $a = new QPushButton("a text");
     $b =& $a;
     $a->setText("text changed");
     echo "\ntesting reference";
     $this->assertEquals($b->text()->__toString(), "text changed", "Creating a reference does not work!");
     echo " passed";
 }
Example #3
0
 public function __construct()
 {
     parent::__construct();
     $quit = new QPushButton(tr("Quit"));
     $quit->setFont(new QFont("Times", 18, QFont::Bold));
     //	    QObject::connect($quit, SIGNAL('clicked()'), qApp(), SLOT('quit()'));
     QObject::connect($quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()'));
     $angle = new LCDRange();
     $angle->setRange(5, 70);
     $cannonField = new CannonField();
     QObject::connect($angle, SIGNAL('valueChanged(int)'), $cannonField, SLOT('setAngle(int)'));
     QObject::connect($cannonField, SIGNAL('angleChanged(int)'), $angle, SLOT('setValue(int)'));
     $gridLayout = new QGridLayout();
     $gridLayout->addWidget($quit, 0, 0);
     $gridLayout->addWidget($angle, 1, 0);
     $gridLayout->addWidget($cannonField, 1, 1, 2, 1);
     $gridLayout->setColumnStretch(1, 10);
     $this->setLayout($gridLayout);
     $angle->setValue(60);
     $angle->setFocus();
 }
Example #4
0
 private function create_button($text, $icon, $slot = '', $enabled = true, $align = 'left')
 {
     $widget = new QWidget($this);
     $button = new QPushButton($widget);
     $button->text = $text;
     $button->setMinimumSize(200, 36);
     $button->enabled = $enabled;
     $button->styleSheet = "text-align:{$align};padding-left:50px;padding-right:20px;font-size:14px;";
     $label = new QLabel($widget);
     $label->icon = $this->iconsPath . "/{$icon}";
     $label->resize(32, 32);
     $label->enabled = $enabled;
     $label->move(10, 0);
     if (!empty($slot)) {
         $button->connect(SIGNAL('clicked(bool)'), $this, $slot);
         $label->connect(SIGNAL('mouseClicked()'), $button, SLOT('click()'));
     }
     $layout = new QHBoxLayout();
     $layout->setContentsMargins(0, 6, 0, 0);
     $layout->addWidget($button);
     $widget->setLayout($layout);
     return $widget;
 }
Example #5
0
<?php

/****************************************************************
 **
 ** Qt tutorial 3
 **
 ** original:
 ** http://doc.trolltech.com/4.1/tutorial-t3.html
 **
 ****************************************************************/
if (!extension_loaded('php_qt')) {
    dl('php_qt.' . PHP_SHLIB_SUFFIX);
}
$app = new QApplication($argc, $argv);
$window = new QWidget();
$window->resize(200, 120);
$quit = new QPushButton("Quit", $window);
$quit->setFont(new QFont("Times", 18, QFont::Bold));
$quit->setGeometry(10, 40, 180, 40);
QObject::connect($quit, SIGNAL('clicked()'), $app, SLOT('quit()'));
$window->show();
$app->exec();
Example #6
0
 public function createButton($component)
 {
     $componentsPath = $this->componentsPath;
     $componentPath = "{$componentsPath}/{$component}/component.php";
     $r = array();
     if (file_exists($componentPath) && is_file($componentPath)) {
         include $componentPath;
     } else {
         return;
     }
     if (!isset($r['group']) || $r['group'] == 'NoVisual') {
         return;
     }
     if (isset($r['parent']) && !empty(trim($r['parent']))) {
         $parentClass = $r['parent'];
     } else {
         $parentClass = null;
     }
     $objectName = isset($r['objectName']) ? "pqcreatebutton_{$component}_{$r[objectName]}" : "pqcreatebutton_{$component}_{$component}";
     $buttonText = isset($r['title']) ? $r['title'] : $component;
     $button = new QPushButton($this->componentsPanel);
     $button->objectName = $objectName;
     $button->text = $buttonText;
     $button->styleSheet = "text-align: left";
     $button->minimumHeight = 30;
     $button->icon = "{$componentsPath}/{$component}/icon.png";
     $button->flat = true;
     $button->creator = true;
     $button->setIconSize(24, 24);
     $button->parentClass = $parentClass;
     if (isset($r['defobjw']) && isset($r['defobjh'])) {
         $button->defobjw = $r['defobjw'];
         $button->defobjh = $r['defobjh'];
     }
     $button->connect(SIGNAL("mousePressed(int,int,int,int,int)"), $this, SLOT("createObject(int,int,int,int,int)"));
     $button->connect(SIGNAL("mouseMoved(int,int,int,int)"), $this, SLOT("moveObject(int,int,int,int)"));
     $button->connect(SIGNAL('mouseReleased(int,int,int,int,int)'), $this, SLOT('testCreate(int,int,int,int,int)'));
     $this->componentsLayout->addWidget($button);
 }
Example #7
0
<?php

/****************************************************************
 **
 ** Qt tutorial 1
 **
 ** original:
 ** http://doc.trolltech.com/4.1/tutorial-t1.html
 **
 ****************************************************************/
if (!extension_loaded('php_qt')) {
    dl('php_qt.' . PHP_SHLIB_SUFFIX);
}
$app = new QApplication($argc, $argv);
$hello = new QPushButton("Hello world!");
$hello->resize(100, 30);
$hello->show();
$app->exec();
Example #8
0
<?php

/****************************************************************
 **
 ** Qt tutorial 2
 **
 ** original:
 ** http://doc.trolltech.com/4.1/tutorial-t2.html
 **
 ****************************************************************/
if (!extension_loaded('php_qt')) {
    dl('php_qt.' . PHP_SHLIB_SUFFIX);
}
$app = new QApplication($argc, $argv);
$quit = new QPushButton("Quit");
$quit->resize(75, 30);
$quit->setFont(new QFont("Times", 18, QFont::Bold));
QObject::connect($quit, SIGNAL('clicked()'), $app, SLOT('quit()'));
$quit->show();
$app->exec();
Example #9
0
 /**
  * @return QPushButton
  */
 private function createButton(QString $text, QWidget $receiver, $member)
 {
     $button = new QPushButton($text);
     $button->connect($button, SIGNAL("clicked()"), $receiver, (string) $member);
     return $button;
 }