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(); }
public function setupUi($Dialog) { if ($Dialog->objectName()->isEmpty()) { $Dialog->setObjectName(QString::fromUtf8("Dialog")); } $size = new QSize(394, 311); $size = $size->expandedTo($Dialog->minimumSizeHint()); $Dialog->resize($size); $this->buttonBox = new QDialogButtonBox($Dialog); $buttonBox = $this->buttonBox; // scope $buttonBox->setObjectName(QString::fromUtf8("buttonBox")); $buttonBox->setGeometry(new QRect(40, 270, 341, 32)); $buttonBox->setOrientation(Qt::Horizontal); $buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::NoButton | QDialogButtonBox::Ok); $this->textBrowser = new QTextBrowser($Dialog); $textBrowser = $this->textBrowser; // scope $textBrowser->setObjectName(QString::fromUtf8("textBrowser")); $textBrowser->setGeometry(new QRect(10, 10, 371, 211)); $this->lineEdit = new QLineEdit($Dialog); $lineEdit = $this->lineEdit; // scope $lineEdit->setObjectName(QString::fromUtf8("lineEdit")); $lineEdit->setGeometry(new QRect(10, 230, 371, 25)); $this->retranslateUi($Dialog); QObject::connect($buttonBox, SIGNAL('accepted()'), $Dialog, SLOT('accept()')); QObject::connect($buttonBox, SIGNAL('rejected()'), $Dialog, SLOT('reject()')); QMetaObject::connectSlotsByName($Dialog); }
public function setupConnections() { $this->quit = new QPushButton(tr("Quit")); $this->quit->setFont(new QFont("Times", 18, QFont::Bold)); QObject::connect($this->quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()')); $this->angle = new LCDRange(); $this->angle->setRange(5, 70); /* $this->cannonField = new CannonField(); */ // QObject::connect($this->angle, SIGNAL('valueChanged(int)'), $this->cannonField, SLOT('setAngle(int)')); // QObject::connect($this->cannonField, SIGNAL('angleChanged(int)'), $this->angle, SLOT('setValue(int)')); }
public function __construct() { parent::__construct(); $this->currentAngle = 45; $this->currentForce = 0; $this->timerCount = 0; $this->autoShootTimer = new QTimer($this); QObject::connect($this->autoShootTimer, SIGNAL('timeout()'), $this, SLOT('moveShot()')); $this->shootAngle = 0; $this->shootForce = 0; $this->setPalette(new QPalette(new QColor(250, 250, 200))); $this->setAutoFillBackground(true); $this->barrelRect = new QRect(30, -5, 20, 10); }
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(); }
{ private $mainWidget; public $button1; public $button2; function __construct() { $mainWidget = new QWidget(); parent::__construct(QBoxLayout::TopToBottom, $mainWidget); $this->mainWidget = $mainWidget; $this->button1 = new QPushButton("About Qt!"); $this->button2 = new QPushButton("Quit"); $this->addWidget($this->button1); $this->addWidget($this->button2); } function __destruct() { $this->button1 = 0; $this->button2 = 0; $this->mainWidget = 0; } function show() { $this->mainWidget->show(); } } $app = new QApplication($argc, $argv); $box = new Box(); $box->show(); QObject::connect($box->button1, SIGNAL("clicked()"), $app, SLOT("aboutQt()")); QObject::connect($box->button2, SIGNAL("clicked()"), $app, SLOT("quit()")); $app->exec();
<?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();