NewGameWindow::NewGameWindow(QWidget *parent) : QDialog(parent) { QLabel * joueur1Tag = new QLabel("Joueur 1: ", parent); QLabel * joueur2Tag = new QLabel("Joueur 2: ", parent); QLabel * tempsMaxTag = new QLabel("Temps max (min): ", parent); joueur1LE = new QLineEdit(parent); joueur2LE = new QLineEdit(parent); tempsMaxSB = new QSpinBox(parent); tempsMaxSB->setMaximum(20); tempsMaxSB->setMinimum(1); QPushButton * debuterPartieBtn = new QPushButton("Débuter la partie", parent); QPushButton * annulerBtn = new QPushButton("Annuler", parent); connect(annulerBtn, SIGNAL(clicked()),this, SLOT(quitClicked())); connect(debuterPartieBtn, SIGNAL(clicked()),this, SLOT(debuterClicked())); QFormLayout * layout = new QFormLayout; layout->addRow(joueur1Tag, joueur1LE); layout->addRow(joueur2Tag, joueur2LE); layout->addRow(tempsMaxTag, tempsMaxSB); layout->addRow(debuterPartieBtn, annulerBtn); setLayout(layout); show(); setWindowTitle(tr("Nouvelle Partie")); }
Counter::Counter(QWidget *parent) : QWidget(parent) { // Initialize private data members countDisplay = new QLabel(this); count = new QPushButton("Click", this); quit = new QPushButton("Quit", this); layout = new QVBoxLayout; counter = 0; // Add widgets to the layout layout->addWidget(count); layout->addWidget(countDisplay); layout->addWidget(quit); // Create the layout setLayout(layout); // Set up the connections between different pieces of the app. These // connections tell the app to call certain functions when certain events // occur. Look up doc on signals and slots if this is confusing. QObject::connect(count, SIGNAL(clicked()), this, SLOT(showCount())); QObject::connect(quit, SIGNAL(clicked()), this, SLOT(quitClicked())); // Show the initial count before we show the app window. If this happens // after we call show(), then there is no value displayed initially. showCount(); // Show the app window. show(); }
Advisor::Advisor(QWidget *parent) : QWidget(parent) { showAgain = true; //signalMapper = new QSignalMapper(this); display = new QTextEdit(); display->setReadOnly(true); display->setAlignment(Qt::AlignLeft); //display->setMaxLength(20); QFont font = display->font(); font.setPointSize(font.pointSize()); display->setFont(font); QPushButton *adviceButton = createButton(tr("Advice"),SLOT(adviceClicked())); QPushButton *weatherButton = createButton(tr("Weather"), SLOT(weatherClicked())); QPushButton *reminderButton = createButton(tr("Reminder"), SLOT(reminderClicked())); QPushButton *quitButton = createButton(tr("Quit"), SLOT(quitClicked())); QGridLayout *mainLayout = new QGridLayout; //mainLayout->setSizeConstraint(QLayout::SetFixedSize); mainLayout->addWidget(display, 0,0,1,12); mainLayout->addWidget(adviceButton, 1,0,1,12); mainLayout->addWidget(weatherButton, 2, 0, 1, 12); mainLayout->addWidget(reminderButton, 3, 0, 1, 12); mainLayout->addWidget(quitButton, 4 ,0, 1, 12); //connect(signalMapper, SIGNAL(mapped(QString)), this, SIGNAL(clicked(QString))); setLayout(mainLayout); setWindowTitle(tr("Advisor")); }
QmlSettingsMenu::QmlSettingsMenu(QObject* widget) : mSettingsWidget(widget) { connect(mSettingsWidget, SIGNAL(volume(int)), this, SLOT(volumeHandler(int))); connect(mSettingsWidget, SIGNAL(ipAndPort(QString, QString)), this, SLOT(ipAndPortHandler(QString,QString))); connect(mSettingsWidget, SIGNAL(quitClicked()), SIGNAL(buttonBackPushed())); mSettingsWidget->setProperty("ip", settings.value(SettingsKey::IP_KEY)); mSettingsWidget->setProperty("port", settings.value(SettingsKey::PORT_KEY)); mSettingsWidget->setProperty("currentVolumeState", settings.value(SettingsKey::VOLUME_KEY).toInt() / 25); }
void QX::BuildMenu() { menu = QSoftMenuBar::menuFor(this); menu->addAction(tr("Launch"),this,SLOT(launch_clicked())); menu->addAction(tr("Settings"),this,SLOT(settings_clicked())); menu->addAction(tr("Info"),this,SLOT(info_clicked())); menu->addSeparator(); favouritesAction = menu->addAction(tr("Favourites"),this,SLOT(favourites_clicked())); favouritesAction->setCheckable(true); menu->addSeparator(); menu->addAction(tr("Quit"),this,SLOT(quitClicked())); }
void QX::BuildMenu() { #ifdef QTOPIA menu = QSoftMenuBar::menuFor(this); #else menu = mainWin->menuBar()->addMenu("&File"); #endif menu->addAction(tr("Launch"),this,SLOT(launch_clicked())); menu->addAction(tr("Settings"),this,SLOT(settings_clicked())); menu->addAction(tr("Info"),this,SLOT(info_clicked())); menu->addSeparator(); favouritesAction = menu->addAction(tr("Favourites"),this,SLOT(favourites_clicked())); favouritesAction->setCheckable(true); menu->addSeparator(); menu->addAction(tr("Quit"),this,SLOT(quitClicked())); }
optionsDialog::optionsDialog(QWidget *parent, std::string name) : QDialog(parent) { zoomLabel = new QLabel(tr("Zoom factor")); delayLabel = new QLabel(tr("Delay factor")); generationLabel = new QLabel(tr("Generation:")); numberLabel = new QLabel(tr("0")); zoomSB = new QSpinBox; zoomSB->setRange(1,30); delaySB = new QSpinBox; delaySB->setRange(1,10000); zoomSlid = new QSlider(Qt::Horizontal); zoomSlid->setRange(1,30); QObject::connect(zoomSB, SIGNAL(valueChanged(int)), zoomSlid, SLOT(setValue(int))); QObject::connect(zoomSlid, SIGNAL(valueChanged(int)), zoomSB, SLOT(setValue(int))); QObject::connect(zoomSB, SIGNAL(valueChanged(int)), parent, SLOT(zoomChanged(int))); zoomSB->setValue(10); delaySlid = new QSlider(Qt::Horizontal); delaySlid->setRange(1,10000); QObject::connect(delaySB, SIGNAL(valueChanged(int)), delaySlid, SLOT(setValue(int))); QObject::connect(delaySlid, SIGNAL(valueChanged(int)), delaySB, SLOT(setValue(int))); QObject::connect(delaySB, SIGNAL(valueChanged(int)), parent, SLOT(delayChanged(int))); delaySB->setValue(100); quitButton = new QPushButton(tr("&Quit")); playButton = new QPushButton(tr("&Play")); stepButton = new QPushButton(tr("&Step")); QObject::connect(quitButton, SIGNAL(clicked()), parent, SLOT(quitClicked())); QObject::connect(stepButton, SIGNAL(clicked()), parent, SLOT(stepClicked())); QObject::connect(playButton, SIGNAL(clicked()), parent, SLOT(playClicked())); QHBoxLayout *zoomLayout = new QHBoxLayout; zoomLayout->addWidget(zoomLabel); zoomLayout->addWidget(zoomSB); zoomLayout->addWidget(zoomSlid); QHBoxLayout *delayLayout = new QHBoxLayout; delayLayout->addWidget(delayLabel); delayLayout->addWidget(delaySB); delayLayout->addWidget(delaySlid); QHBoxLayout *generationLayout = new QHBoxLayout; generationLayout->addWidget(generationLabel); generationLayout->addStretch(); generationLayout->addWidget(numberLabel); QHBoxLayout *buttonLayout = new QHBoxLayout; buttonLayout->addWidget(quitButton); buttonLayout->addWidget(playButton); buttonLayout->addWidget(stepButton); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(zoomLayout); mainLayout->addLayout(delayLayout); mainLayout->addLayout(generationLayout); mainLayout->addLayout(buttonLayout); setLayout(mainLayout); QString *title = new QString((name + " Controls").c_str()); setWindowTitle(*title); setFixedHeight(sizeHint().height()); }