public function __construct($parent = 0) { parent::__construct($parent); $this->setWindowFlags(Qt::Window); $this->textEdit = new PQPlainTextEdit($this); $this->headerLabel1 = new QLabel($this); $this->setPHPEventListener($this, eventListener); $this->addPHPEventListenerType(QEvent::Close); $buttonsPanel = new QWidget($this); $cancelBtn = new QPushButton($buttonsPanel); $cancelBtn->text = tr('Cancel'); $cancelBtn->onClicked = function ($sender, $event) { $this->close(); }; $okBtn = new QPushButton($buttonsPanel); $okBtn->text = tr('OK'); $okBtn->onClicked = function ($sender, $event) { $this->done(1); }; $buttonsPanelLayout = new QHBoxLayout(); $buttonsPanelLayout->addWidget(new QWidget($buttonsPanel)); // распорка $buttonsPanelLayout->addWidget($cancelBtn); $buttonsPanelLayout->addWidget($okBtn); $buttonsPanelLayout->setMargin(0); $buttonsPanel->setLayout($buttonsPanelLayout); $layout = new QVBoxLayout(); $layout->addWidget($this->headerLabel1); $layout->addWidget($this->textEdit); $layout->addWidget($buttonsPanel); $this->setLayout($layout); }
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 setVisible($visible) { $this->minimizeAction->setEnabled($visible); //$this->maximizeAction->setEnabled(! $this->isMaximized()); $this->restoreAction->setEnabled($this->isMaximized() or !$visible); parent::setVisible($visible); }
public function __construct() { parent::__construct(); $this->currentAngle = 45; $this->setPalette(new QPalette(new QColor(250, 250, 200))); $this->setAutoFillBackground(true); }
function __construct() { parent::__construct(); $this->setFixedSize(200, 120); $this->quit = new QPushButton(tr("Quit"), $this); $this->quit->setGeometry(62, 40, 75, 30); $this->quit->setFont(new QFont("Times", 18, QFont::Bold)); /* the macro qApp is not available in php-qt, we use QApplication::instance() directly. */ $this->connect($this->quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()')); }
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(); $this->lcd = new QLCDNumber(2); $this->lcd->setSegmentStyle(QLCDNumber::Filled); $this->slider = new QSlider(Qt::Horizontal); $this->slider->setRange(0, 99); $this->slider->setValue(0); $this->connect($this->slider, SIGNAL('valueChanged(int)'), $this->lcd, SLOT('display(int)')); $this->connect($this->slider, SIGNAL('valueChanged(int)'), $this, SIGNAL('valueChanged(int)')); $layout = new QVBoxLayout(); $layout->addWidget($this->lcd); $layout->addWidget($this->slider); $this->setLayout($layout); $this->setFocusProxy($this->slider); }
function __construct() { parent::__construct(); $this->quit = new QPushButton(tr("Quit")); $this->quit->setFont(new QFont("Times", 18, QFont::Bold)); $this->connect($this->quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()')); $this->grid = new QGridLayout(); for ($row = 0; $row < 4; ++$row) { for ($column = 0; $column < 4; ++$column) { $this->grid->addWidget(new LCDRange(), $row, $column); } } $this->layout = new QVBoxLayout(); $this->layout->addWidget($this->quit); $this->layout->addLayout($this->grid); $this->setLayout($this->layout); }
function __construct() { parent::__construct(); $this->quit = new QPushButton(tr("Quit")); $this->quit->setFont(new QFont("Times", 18, QFont::Bold)); $this->lcd = new QLCDNumber(2); $this->lcd->setSegmentStyle(QLCDNumber::Filled); $this->slider = new QSlider(Qt::Horizontal); $this->slider->setRange(0, 99); $this->slider->setValue(0); $this->connect($this->quit, SIGNAL('clicked()'), QApplication::instance(), SLOT('quit()')); $this->connect($this->slider, SIGNAL('valueChanged(int)'), $this->lcd, SLOT('display(int)')); $this->layout = new QVBoxLayout(); $this->layout->addWidget($this->quit); $this->layout->addWidget($this->lcd); $this->layout->addWidget($this->slider); $this->setLayout($this->layout); }
public function __construct() { parent::__construct(); $this->screenshotLabel = new QLabel(); $this->screenshotLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); $this->screenshotLabel->setAlignment(Qt::AlignCenter); $this->screenshotLabel->setMinimumSize(240, 160); $this->createOptionsGroupBox(); $this->createButtonsLayout(); $this->mainLayout = new QVBoxLayout(); $this->mainLayout->addWidget($this->screenshotLabel); $this->mainLayout->addWidget($this->optionsGroupBox); $this->mainLayout->addLayout($this->buttonsLayout); $this->setLayout($this->mainLayout); $this->shootScreen(); $this->delaySpinBox->setValue(5); $this->setWindowTitle(tr("Screenshot")); $this->resize(300, 200); }
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(); }
public function __construct(QFileInfo $fileInfo, QWidget $parent = NULL) { parent::__construct($parent); $topLabel = new QLabel(tr("Open with:")); $applicationsListBox = new QListWidget(); $applications = array(); for ($i = 1; $i <= 30; ++$i) { $applications[] = tr("Application %1")->arg($i); } $applicationsListBox->insertItems(0, $applications); $alwaysCheckBox = new QCheckBox(); if ($fileInfo->suffix()->isEmpty()) { $alwaysCheckBox = new QCheckBox(tr("Always use this application to " . "open this type of file")); } else { $alwaysCheckBox = new QCheckBox(tr("Always use this application to " . "open files with the extension '%1'") . arg($fileInfo->suffix())); } $layout = new QVBoxLayout(); $layout->addWidget($topLabel); $layout->addWidget($applicationsListBox); $layout->addWidget($alwaysCheckBox); $this->setLayout($layout); }
public function __construct() { parent::__construct(); $this->layout = new QVBoxLayout($this); // Load the test xml $unicodeXml = new DOMDocument(); $unicodeXml->load("unicode.xml"); $xpath = new DOMXPath($unicodeXml); $dataNodes = $xpath->query("/test/data"); // Loop on all data node and create buttons foreach ($dataNodes as $data) { $this->buttons[] = new QLineEdit(QString::fromUtf8($data->nodeValue, -1), $this); foreach ($data->attributes as $attribute) { $this->layout->addWidget(new QLabel($attribute->name . ": " . $attribute->value)); } $this->layout->addWidget($this->buttons[count($this->buttons) - 1]); } $this->buttons[] = new QLineEdit("Test", $this); $this->layout->addWidget($this->buttons[count($this->buttons) - 1]); $this->buttons[] = new QLineEdit("second Test", $this); $this->layout->addWidget($this->buttons[count($this->buttons) - 1]); }
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; }
public function sizeHint() { return parent::sizeHint(); }
function testAmbiguousMethodCall() { echo "\ntesting ambiguous method call"; $w = new QWidget(); $w->setPalette(new QPalette(new QColor(250, 250, 200))); echo " passed"; }
public function __construct() { parent::__construct(); $this->button = new QPushButton(tr("quit"), $this); $this->connect($this->button, SIGNAL('clicked()'), QCoreApplication::instance(), SLOT('quit()')); }
public function addTab($widget, &$codegen, $text, $icon = null) { $index = $this->tabbar->addTab($text); if ($icon != null) { $this->tabbar->setTabIcon($index, $icon); } $stackArea = new QWidget(); $scrollArea_viewport = new QWidget(); $scrollArea_viewport->setPalette("#ffffff"); $scrollArea_viewport->objectName = '___pq_creator__pqtabwidget_scrollarea_viewport'; $scrollArea_viewport->styleSheet = '#___pq_creator__pqtabwidget_scrollarea_viewport > QWidget { padding-top:2px; }'; $scrollArea = new QScrollArea($stackArea); $scrollArea->objectName = '___pq_creator__pqtabwidget_scrollarea_'; $scrollArea->setViewport($scrollArea_viewport); $scrollArea->setWidget($widget); $scrollArea->styleSheet = '#___pq_creator__pqtabwidget_scrollarea_ { border: none; }'; $widget->resize(300, 300); $widget->isFormAreaWidget = true; $widget->tabIndex = $index; $stack = new QStackedWidget($stackArea); $stack->objectName = '___pq_creator__pqtabwidget_stackarea_stack_'; $stack->addWidget($scrollArea); if ($codegen != null) { $stack->addWidget($codegen); } // $toolbar = $this->createToolBar($stackArea, $stack); $stackArea_layout = new QVBoxLayout(); $stackArea_layout->setMargin(0); // $stackArea_layout->addWidget($toolbar); $stackArea_layout->addWidget($stack); $stackArea->setLayout($stackArea_layout); $this->stack->addWidget($stackArea); }
public function __construct() { parent::__construct(); }
public function sizeHint() { echo "my own sizeHint\n"; return parent::sizeHint(); }
function testObjectLifeCycle() { echo "testing deletion of object "; $color_a = new QColor(1, 3, 5); $color_a->__destruct(); unset($color_a); $this->assertFalse(isset($color_a), "Object wasn't deleted properly\n"); echo "passed\n"; echo "testing returning a Stack item, checking values "; $widget_a = new QWidget(); $widget_a->resize(24, 28); $size_a = $widget_a->size(); $this->assertEquals($size_a->width(), $widget_a->width(), "return value of QWidget::size() is not correct\n"); echo "passed\n"; echo "testing returning a Stack item, changing values "; $widget_a->resize(26, 30); $size_b = $widget_a->size(); $this->assertEquals($size_b->width(), 26, ""); $this->assertEquals($size_a->width(), 24, ""); // $this->assertEquals( $widget_a->size(), $size_b->width() ); }
/** * calling the ambiguous method update() of class QWidget which takes either a QRect or a QRegion as argument * <code> * QWidget->update( new QRect( 1, 2, 3, 4 ) ); * QWidget->update( new QRegion( 1, 2, 3, 4, QRegion::Rectangle ) ); * </code> */ function testAmbiguousMethodCallObject() { echo "\ntesting ambiguous method call with different objects as arguments"; $w = new QWidget(); $w->update(1, 2, 3, 4); $w->update(new QRect(1, 2, 3, 4)); $w->update(new QRegion(1, 2, 3, 4, QRegion::Rectangle)); echo " passed"; }
<?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();
function eventFilter($target, $event) { if ($target == $this->display) { if ($event->type() == QEvent::MouseButtonPress || $event->type() == QEvent::MouseButtonDblClick || $event->type() == QEvent::MouseButtonRelease || $event->type() == QEvent::ContextMenu) { qstatic_cast($event, "QMouseEvent"); if ($event->buttons() & Qt::LeftButton) { $newPalette = $this->palette(); $newPalette->setColor(QPalette::Base, $this->display->palette()->color(QPalette::Text)); $newPalette->setColor(QPalette::Text, $this->display->palette()->color(QPalette::Base)); $this->display->setPalette($newPalette); } else { $this->display->setPalette($this->palette()); } return true; } } return parent::eventFilter($target, $event); }