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 __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 createMessageGroupBox() { $this->messageGroupBox = new QGroupBox($this->tr("Balloon Message")); $this->typeLabel = new QLabel($this->tr("Type:")); $this->typeComboBox = new QComboBox(); $this->typeComboBox->addItem($this->tr("None"), new QVariant(QSystemTrayIcon::NoIcon)); $this->typeComboBox->addItem($this->style()->standardIcon(QStyle::SP_MessageBoxInformation), $this->tr("Information"), new QVariant(QSystemTrayIcon::Information)); $this->typeComboBox->addItem($this->style()->standardIcon(QStyle::SP_MessageBoxWarning), $this->tr("Warning"), new QVariant(QSystemTrayIcon::Warning)); $this->typeComboBox->addItem($this->style()->standardIcon(QStyle::SP_MessageBoxCritical), $this->tr("Critical"), new QVariant(QSystemTrayIcon::Critical)); $this->typeComboBox->setCurrentIndex(1); $this->durationLabel = new QLabel($this->tr("Duration:")); $this->durationSpinBox = new QSpinBox(); $this->durationSpinBox->setRange(5, 60); $this->durationSpinBox->setSuffix(" s"); $this->durationSpinBox->setValue(15); $this->durationWarningLabel = new QLabel($this->tr("(some systems might " . "ignore this hint)")); $this->durationWarningLabel->setIndent(10); $this->titleLabel = new QLabel($this->tr("Title:")); $this->titleEdit = new QLineEdit($this->tr("Cannot connect to network")); $this->bodyLabel = new QLabel($this->tr("Body:")); $this->bodyEdit = new QTextEdit(); $this->bodyEdit->setPlainText($this->tr("Don't believe me. Honestly, I " . "don't have a clue.\nClick this balloon for details.")); /* */ $this->showMessageButton = new QPushButton($this->tr("Show Message")); $this->showMessageButton->setDefault(True); $messageLayout = new QGridLayout(); $messageLayout->addWidget($this->typeLabel, 0, 0); $messageLayout->addWidget($this->typeComboBox, 0, 1, 1, 2); $messageLayout->addWidget($this->durationLabel, 1, 0); $messageLayout->addWidget($this->durationSpinBox, 1, 1); $messageLayout->addWidget($this->durationWarningLabel, 1, 2, 1, 3); $messageLayout->addWidget($this->titleLabel, 2, 0); $messageLayout->addWidget($this->titleEdit, 2, 1, 1, 4); $messageLayout->addWidget($this->bodyLabel, 3, 0); $messageLayout->addWidget($this->bodyEdit, 3, 1, 2, 4); $messageLayout->addWidget($this->showMessageButton, 5, 4); $messageLayout->setColumnStretch(3, 1); $messageLayout->setRowStretch(4, 1); $this->messageGroupBox->setLayout($messageLayout); }