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(); }
private function createButtonsLayout() { $this->newScreenshotButton = $this->createButton(tr("New Screenshot"), $this, SLOT("newScreenshot()")); $this->saveScreenshotButton = $this->createButton(tr("Save Screenshot"), $this, SLOT("saveScreenshot()")); $this->quitScreenshotButton = $this->createButton(tr("Quit"), $this, SLOT("close()")); $this->buttonsLayout = new QHBoxLayout(); $this->buttonsLayout->addStretch(); $this->buttonsLayout->addWidget($this->newScreenshotButton); $this->buttonsLayout->addWidget($this->saveScreenshotButton); $this->buttonsLayout->addWidget($this->quitScreenshotButton); }
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); }
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; }
private function createToolBar($stackArea, $stack) { $toolbar = new QWidget($stackArea); $projectButton = new QPushButton($toolbar); $projectButton->text = tr('Project'); $projectButton->checkable = true; $projectButton->checked = true; $projectButton->autoExclusive = true; $projectButton->onClicked = function ($button, $event) use($stack) { $stack->setCurrentIndex(0); $codegen = $stack->widget(1); if ($codegen != null) { $codegen->disableRules(); } }; $sourceButton = new QPushButton($toolbar); $sourceButton->text = tr('Source'); $sourceButton->checkable = true; $sourceButton->autoExclusive = true; $sourceButton->onClicked = function ($button, $event) use($stack) { $stack->setCurrentIndex(1); $codegen = $stack->widget(1); if ($codegen != null) { $codegen->enableRules(); $codegen->rehighlight(); } }; $toolbar_layout = new QHBoxLayout(); $toolbar_layout->addWidget($projectButton); $toolbar_layout->addWidget($sourceButton); $toolbar->setLayout($toolbar_layout); return $toolbar; }
public function createIconGroupBox() { $this->iconGroupBox = new QGroupBox($this->tr("Tray Icon")); $this->iconLabel = new QLabel("Icon:"); $this->iconComboBox = new QComboBox(); $this->iconComboBox->addItem(new QIcon("./images/bad.svg"), $this->tr("Bad")); $this->iconComboBox->addItem(new QIcon("./images/heart.svg"), $this->tr("Heart")); $this->iconComboBox->addItem(new QIcon("./images/trash.svg"), $this->tr("Trash")); $this->showIconCheckBox = new QCheckBox($this->tr("Show icon")); $this->showIconCheckBox->setChecked(True); $iconLayout = new QHBoxLayout(); $iconLayout->addWidget($this->iconLabel); $iconLayout->addWidget($this->iconComboBox); $iconLayout->addStretch(); $iconLayout->addWidget($this->showIconCheckBox); $this->iconGroupBox->setLayout($iconLayout); }