bool Widgets::slider( QWidget *parent, const QString& title, const QString& text, int minValue, int maxValue, int step, int &result ) { KDialog dlg( parent ); kapp->setTopWidget( &dlg ); dlg.setCaption( title ); dlg.setButtons( KDialog::Ok|KDialog::Cancel ); dlg.setModal( true ); dlg.setDefaultButton( KDialog::Ok ); KVBox* vbox = new KVBox( &dlg ); dlg.setMainWidget( vbox ); QLabel label (vbox); label.setText (text); QSlider slider (vbox); slider.setMinimum( minValue ); slider.setMaximum( maxValue ); slider.setSingleStep( step ); slider.setTickPosition ( QSlider::TicksAbove ); slider.setOrientation( Qt::Horizontal ); handleXGeometry(&dlg); const bool retcode = (dlg.exec() == QDialog::Accepted); if (retcode) result = slider.value(); return retcode; }
QWidget* CameraParamsWidget::createEditorFor(const camera_v4l2::CameraParam& param) { if(!param.choices.empty()) { QComboBox* box = new QComboBox(m_w); for(uint i = 0; i < param.choices.size(); ++i) { box->addItem( param.choices[i].label.c_str(), param.choices[i].value ); if(param.choices[i].value == param.value) box->setCurrentIndex(i); } box->setProperty("paramID", param.id); connect(box, SIGNAL(activated(int)), SLOT(updateComboBox())); return box; } if(param.minimum == 0 && param.maximum == 1) { QCheckBox* box = new QCheckBox(m_w); box->setChecked(param.value); box->setProperty("paramID", param.id); connect(box, SIGNAL(clicked(bool)), SLOT(updateCheckBox(bool))); return box; } QSlider* slider = new QSlider(Qt::Horizontal, m_w); slider->setMinimum(param.minimum); slider->setMaximum(param.maximum); slider->setValue(param.value); slider->setProperty("paramID", param.id); connect(slider, SIGNAL(valueChanged(int)), SLOT(updateSlider(int))); return slider; }
MyWidget::MyWidget(QWidget *parent) : QWidget(parent) { setWindowTitle(tr("Test thread project")); setFixedSize(550, 420); bQuit = new QPushButton(tr("&Quit")); bRnd = new QPushButton ("&RND"); bCountDown = new QPushButton ("&Start CountDown"); bQuit->setFont(QFont("Courier", 18, QFont::Bold)); bRnd->setFont(QFont("Courier", 18, QFont::Bold)); bCountDown->setFont(QFont("Courier", 18, QFont::Bold)); lcd = new QLCDNumber(); lcd->setSegmentStyle(QLCDNumber::Filled); lcd->setAutoFillBackground(1); lcd->display(0); QSlider *slider = new QSlider(Qt::Horizontal); slider->setRange(0, 999); slider->setValue(0); // line3 = new QLineEdit (this); lnMSTime = new QLineEdit (this); QVBoxLayout *layout = new QVBoxLayout; QHBoxLayout *hLayout = new QHBoxLayout; connect(bQuit, SIGNAL(clicked()), qApp, SLOT(quit())); connect(bCountDown, SIGNAL(clicked()), this, SLOT (StartMyThread())); connect(bRnd, SIGNAL(clicked ()), this, SLOT (setValue ())); connect(slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int))); layout->addWidget(lcd); layout->addWidget(slider); layout->addWidget(lnMSTime); hLayout->addWidget(bRnd); hLayout->addWidget(bQuit); hLayout->addWidget(bCountDown); layout->addLayout(hLayout); setLayout(layout); }
void QtSliderFactory::slotRangeChanged(QtProperty *property, int min, int max) { if (!m_createdEditors.contains(property)) return; QtIntPropertyManager *manager = this->propertyManager(property); if (!manager) return; QListIterator<QSlider *> itEditor(m_createdEditors[property]); while (itEditor.hasNext()) { QSlider *editor = itEditor.next(); editor->blockSignals(true); editor->setRange(min, max); editor->setValue(manager->value(property)); editor->blockSignals(false); } }
ConnectWidget::ConnectWidget( QWidget *parent, const char *name) : QVBox(parent,name){ QPushButton *button = new QPushButton("Sair",this,"quit"); connect(button, SIGNAL(clicked()), qApp, SLOT(quit())); QLCDNumber *lcd = new QLCDNumber(2,this,"lcd"); QSlider *slider = new QSlider(Horizontal,this,"Slider"); slider->setRange(0, 99); slider->setValue(0); slider->setPageStep(1); connect( slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)) ); QPushButton *add = new QPushButton("Somar",this,"add"); connect(add, SIGNAL(clicked()), slider, SLOT(addStep())); QPushButton *subtract = new QPushButton("Subtrair",this,"subtract"); connect(subtract, SIGNAL(clicked()), slider, SLOT(subtractStep())); }
void ParamWidget::SetDouble(const QString& name, double val) { QWidget* widget = GetWidget(name); QDoubleSpinBox* spinbox = dynamic_cast<QDoubleSpinBox*>(widget); if (spinbox) { spinbox->setValue(val); return; } QSlider* slider = dynamic_cast<QSlider*>(widget); if (slider) { const double min = slider->property("min").toDouble(); const double step = slider->property("step").toDouble(); const int position = static_cast<int>(round((val - min) / step)); slider->setValue(position); return; } throw std::runtime_error("Unable to determine widget type for param " + name.toStdString()); }
void QxtSpanSliderPrivate::handleMousePress(const QPoint& pos, QStyle::SubControl& control, int value, SpanHandle handle) { QStyleOptionSlider opt; initStyleOption(&opt, handle); QSlider* p = &qxt_p(); const QStyle::SubControl oldControl = control; control = p->style()->hitTestComplexControl(QStyle::CC_Slider, &opt, pos, p); const QRect sr = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, p); if (control == QStyle::SC_SliderHandle) { position = value; offset = pick(pos - sr.topLeft()); lastPressed = handle; p->setSliderDown(true); } if (control != oldControl) p->update(sr); }
Console::Console(QWidget *parent) : QWidget(parent) { QPushButton* NewWorld = new QPushButton("New world", this); NewWorld->setFixedSize(100, 30); connect(NewWorld, SIGNAL(clicked(bool)), parent, SLOT(SetNewWorld())); QPushButton* Load = new QPushButton("Load world", this); Load->setFixedSize(100, 30); fd_load = new QFileDialog(this, "Loading"); fd_load->setFileMode(QFileDialog::ExistingFile); connect(Load, SIGNAL(clicked()), fd_load, SLOT(show())); connect(fd_load, SIGNAL(fileSelected(const QString&)), this, SLOT(FileChosenLoad(const QString&))); QPushButton* Save = new QPushButton("Save world", this); Save->setFixedSize(100, 30); connect(Save, SIGNAL(clicked()), parent, SLOT(SaveFile())); Pause = new QPushButton("Start", this); Pause->setFixedSize(100, 30); connect(Pause, SIGNAL(clicked(bool)), parent, SLOT(Pause())); connect(parent, SIGNAL(Paused(const QString&)), this, SLOT(ChangeText(const QString&))); QSlider* slider = new QSlider(this); slider->setRange(0, 500); slider->setValue(250); slider->setOrientation(Qt::Horizontal); connect(slider, SIGNAL(valueChanged(int)), parent, SLOT(SetPeriod(int))); QLabel* label = new QLabel("<p align = center>- Speed +</p>", this); QVBoxLayout* vl = new QVBoxLayout(this); vl->addWidget(NewWorld); vl->addWidget(Load); vl->addWidget(Save); vl->addWidget(Pause); vl->addWidget(slider); vl->addWidget(label); setLayout(vl); }
void MainWidget::onElementSizeChanged(int value) { QSlider* notifier = qobject_cast<QSlider*>(sender()); QSlider* fbslider; // Zdecyduj dla ktorej kontrolki wywolano zdarzenie if(notifier == hsXElementSize) { lbXElementSize->setText(QLatin1String("Horizontal: ") + QString::number(2 * value + 1)); fbslider = hsYElementSize; } else { lbYElementSize->setText(QString::fromLatin1("Vertical: ") + QString::number(2 * value + 1)); fbslider = hsXElementSize; } // Jesli mamy zaznaczone 1:1 ratio if (cbSquare->checkState() == Qt::Checked) { if (fbslider->value() != value) { disableRecomputing = true; fbslider->setValue(value); } } emit structuringElementChanged(); // Czy trzeba ponownie wykonac obliczenia w zwiazku ze zmiana // rozmiaru elementu strukturalnego if (!disableRecomputing) { if((cbAutoTrigger->isChecked() && !rbNone->isChecked()) || cameraOn) { emit recomputeNeeded(); } } disableRecomputing = false; }
QWidget *dSettingWindow::createWidget() { QWidget * widget = new QWidget(); QVBoxLayout *layout = new QVBoxLayout; layout->setMargin(1); layout->setSpacing(5); layout->addWidget( new QLabel("Непрозрачноть окна (заначения от 0 до 100).<br>Прозрачные окна имеют проблемы с прорисовкой!") ); QSpinBox *opacitySpinBox = new QSpinBox; opacitySpinBox->setRange(30, 100); opacitySpinBox->setSingleStep(1); opacitySpinBox->setValue(int(window->windowOpacity()*100)); connect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(opacityValueChanged(int))); QSlider *opacitySlider = new QSlider(Qt::Horizontal); opacitySlider->setFocusPolicy(Qt::StrongFocus); opacitySlider->setTickPosition(QSlider::TicksBothSides); opacitySlider->setTickInterval(10); opacitySlider->setSingleStep(1); opacitySlider->setMaximum ( 100 ); opacitySlider->setMinimum ( 30 ); opacitySlider->setValue(opacitySpinBox->value()); connect(opacitySlider, SIGNAL(valueChanged(int)), opacitySpinBox, SLOT(setValue(int))); connect(opacitySpinBox, SIGNAL(valueChanged(int)), opacitySlider, SLOT(setValue(int))); QHBoxLayout *opacityLayout = new QHBoxLayout; opacityLayout->setSpacing(15); opacityLayout->addWidget( opacitySpinBox ); opacityLayout->addWidget( opacitySlider ); layout->addItem( opacityLayout ); layout->addWidget( new QLabel("Изменение рамки окна. Есть возможность использовать стандартное окно,<br> но тогда пропадет эффект \"магнетизма\" окон.") ); QHBoxLayout *skinLayout = new QHBoxLayout; skinLayout->setSpacing(15); skinPushButton = new QPushButton(tr("Load skin")); skinPushButton->setDefault(true); skinPushButton->setIcon(QIcon(tr("pic/open32x32.png"))); connect(skinPushButton, SIGNAL(clicked(bool)), this, SLOT(clickedSkinButton(bool))); skinLayout->addWidget( skinPushButton ); QCheckBox *standartFrameCheckBox = new QCheckBox(tr("Стандартная рамка окна")); connect(standartFrameCheckBox, SIGNAL(stateChanged(int)), this, SLOT(stateChanged(int))); skinLayout->addWidget( standartFrameCheckBox ); skinLayout->addStretch ( 1 ); layout->addItem(skinLayout); widget->setLayout(layout); return widget; };
void MusicSoundKMicroSettingPopWidget::initWidget() { setFixedSize(54, 24); setTranslucentBackground(); m_recordCore = nullptr; m_containWidget->setFixedSize(310, 190); m_containWidget->setStyleSheet(MusicUIObject::MBackgroundStyle08 + MusicUIObject::MColorStyle03); QCheckBox *checkBox = new QCheckBox(tr("Hear Yourself Singing"), m_containWidget); checkBox->setGeometry(10, 20, 280, 25); checkBox->setStyleSheet(MusicUIObject::MCheckBoxStyle05); QCheckBox *checkBox2 = new QCheckBox(tr("Noise Elimination"), m_containWidget); checkBox2->setGeometry(10, 50, 280, 25); checkBox2->setStyleSheet(MusicUIObject::MCheckBoxStyle05); #ifdef Q_OS_UNIX checkBox->setFocusPolicy(Qt::NoFocus); checkBox2->setFocusPolicy(Qt::NoFocus); #endif QLabel *microIconLabel = new QLabel(m_containWidget); microIconLabel->setGeometry(10, 92, 26, 18); QSlider *slider = new QSlider(Qt::Horizontal, m_containWidget); slider->setGeometry(36, 90, 150, 25); slider->setStyleSheet(QString("QSlider{%1}").arg(MusicUIObject::MBackgroundStyle01) + MusicUIObject::MSliderStyle01); slider->setRange(0, 100); slider->setValue(100); connect(slider, SIGNAL(valueChanged(int)), SLOT(volumeChanged(int))); QLabel *inputLabel = new QLabel(tr("Input"), m_containWidget); inputLabel->setGeometry(10, 120, 50, 25); inputLabel->setStyleSheet(MusicUIObject::MBackgroundStyle01); m_inputComboBox = new QComboBox(m_containWidget); m_inputComboBox->setGeometry(60, 120, 230, 25); m_inputComboBox->setStyleSheet(MusicUIObject::MBorderStyle04); m_inputComboBox->setItemDelegate(new QStyledItemDelegate(m_inputComboBox)); m_inputComboBox->view()->setStyleSheet(MusicUIObject::MScrollBarStyle01); foreach(const QAudioDeviceInfo &info, QAudioDeviceInfo::availableDevices(QAudio::AudioInput)) { m_inputComboBox->addItem(info.deviceName()); }
void UnicornVolumeSlider::installFilters() { QToolButton* muteButton = findChild<QToolButton*>(); if( muteButton ) muteButton->installEventFilter( this ); QSlider* volumeSlider = findChild<QSlider*>(); if( volumeSlider ) { volumeSlider->setOrientation( Qt::Vertical ); volumeSlider->installEventFilter( this ); connect( volumeSlider, SIGNAL(valueChanged(int)), SLOT(onVolumeValueChanged(int))); } setFixedWidth( 30 ); layout()->setContentsMargins( 0, 10, 0, 10); setAutoFillBackground( false ); }
void ZerosEditor::on_instance_clicked(Metabot::Component *instance) { auto anchor = instance->aboveAnchor(); if (anchor) { auto anchors = robot->getAnchors(); int n = 0; for (auto robotAnchor : anchors) { if (robotAnchor == anchor) { if (n < sliders.size()) { this->activateWindow(); this->setFocus(); QSlider *slider = sliders[n]; slider->setFocus(); } } n++; } } }
void AbstractCameraManager::on_propertyCheckbox_changed(int state) { if( selectedItem == NULL ) return; CameraProperty* prop = reinterpret_cast<CameraProperty*>( sender()->property("CameraProperty").value<quintptr>() ); qDebug() << sender() << prop->getName().c_str(); prop->setAuto(state == Qt::Checked); cameraTree_recursiveSetProperty(selectedItem, prop); //(de)activate slider if( prop->getType() == CameraManager::AUTOTRIGGER ) return; QSlider* slider = reinterpret_cast<QSlider*>( sender()->property("TreeWidgetSlider").value<quintptr>() ); qDebug() << "Qslider" << slider; if(state != Qt::Checked) { slider->setEnabled(true); slider->setValue(prop->getValueToSlider()); } else { slider->setEnabled(false); } }
void ParamWidget::AddInt(const QString& name, int min, int max, int step, int initial_value, DisplayHint display_hint) { ExpectNameNotFound(name); if (display_hint == DisplayHint::kSpinBox) { QSpinBox* spinbox = new QSpinBox(this); spinbox->setRange(min, max); spinbox->setSingleStep(step); spinbox->setValue(initial_value); spinbox->setProperty("param_widget_type", kParamInt); widgets_[name] = spinbox; AddLabeledRow(name, spinbox); connect(spinbox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), [this, name](int val) { emit ParamChanged(name); }); } else if (display_hint == DisplayHint::kSlider) { QWidget* row_widget = new QWidget(this); QHBoxLayout* row_hbox = new QHBoxLayout(row_widget); QSlider* slider = new QSlider(Qt::Horizontal, this); slider->setRange(min, max); slider->setSingleStep(step); slider->setValue(initial_value); slider->setProperty("param_widget_type", kParamInt); QLabel* label = new QLabel(this); label->setText(QString::number(initial_value)); row_hbox->addWidget(new QLabel(name, this)); row_hbox->addWidget(slider); row_hbox->addWidget(label); widgets_[name] = slider; layout_->addWidget(row_widget); connect(slider, &QSlider::valueChanged, [this, name, label](int value) { label->setText(QString::number(value)); emit ParamChanged(name); }); } else { throw std::invalid_argument("Invalid display hint"); } }
void IntervalSlider::setupUi() { QVBoxLayout* intervalLyt = new QVBoxLayout(); setLayout(intervalLyt); QHBoxLayout* intervalNamesLyt = new QHBoxLayout(); intervalLyt->addLayout(intervalNamesLyt); QSlider* slider = new QSlider(Qt::Horizontal); slider->setTickPosition(QSlider::TicksBelow); intervalLyt->addWidget(slider); QHBoxLayout* demiToneScaleLyt = new QHBoxLayout(); intervalLyt->addLayout(demiToneScaleLyt); for (int i=0; i<15; ++i) { QLabel* demiToneMarkerLbl = new QLabel(QString::number(i)); demiToneScaleLyt->addWidget(demiToneMarkerLbl); } }
void ZoomWidget::setZoom(qreal zoom) { int intZoom = qRound(zoom * 100); d->mZoomLabel->setText(QString("%1%").arg(intZoom)); // Don't change slider value if we come here because the slider change, // avoids choppy sliding scroll. if (!d->mZoomUpdatedBySlider) { QSlider* slider = d->mZoomSlider->slider(); SignalBlocker blocker(slider); int value = sliderValueForZoom(zoom); if (value < slider->minimum()) { // It is possible that we are called *before* setMinimumZoom() as // been called. In this case, define the minimum ourself. d->mZoomSlider->setMinimum(value); } d->mZoomSlider->setValue(value); } }
void AbstractCameraManager::updateProperties() { AbstractCamera* selected = selectedCamera; if( selected == NULL ) return ; for( int i = propertiesList.topLevelItemCount()-1; i>=0; i--) { QTreeWidgetItem* item = propertiesList.topLevelItem(i); QCheckBox* checkBox = qobject_cast<QCheckBox*>( propertiesList.itemWidget(item, Ui::PropertyAuto) ); CameraManager::CameraProperty * prop = reinterpret_cast<CameraManager::CameraProperty*>( checkBox->property("CameraProperty").value<quintptr>() ); QSlider* slider = reinterpret_cast<QSlider*>( checkBox->property("TreeWidgetSlider").value<quintptr>() ); //qDebug() << "updating:" << prop->getName().c_str(); selected->updateProperty(prop); item->setText(Ui::PropertyValue, prop->formatValue() ); checkBox->setChecked(prop->getAuto()); if( prop->getType() == CameraManager::AUTOTRIGGER ) continue; slider->setValue(prop->getValueToSlider()); slider->setEnabled(!prop->getAuto()); } }
QWidgetAction *ExampleController::getMenuWidget() { QSlider* slider = new QSlider(nullptr); slider->setOrientation(Qt::Horizontal); slider->setMinimum(100); slider->setMaximum(1000); slider->setValue(speed); QLabel* label = new QLabel("Speed", nullptr); QHBoxLayout* layout = new QHBoxLayout(nullptr); layout->addWidget(label); layout->addWidget(slider); QWidget* widget = new QWidget(nullptr); widget->setLayout(layout); QWidgetAction* action = new QWidgetAction(nullptr); action->setDefaultWidget(widget); connect(slider, SIGNAL(valueChanged(int)), this, SLOT(speedChanged(int))); return action; }
int main(int argc, char** argv) { QApplication app( argc, argv ); QWidget* wid = new QWidget; QVBoxLayout* lay = new QVBoxLayout; int resolution = 1000; // gui::screw_viewer* viewer = new gui::screw_viewer( wid ); // gui::patch_viewer* viewer = new gui::patch_viewer( wid ); gui::curve_viewer* viewer = new gui::curve_viewer( wid ); viewer->resolution( resolution ); QString filename(argv[1]); QSlider* slider = new QSlider ( Qt::Horizontal, wid ); slider->setMaximum( resolution ); QPushButton* button = new QPushButton("&Add", wid); QObject::connect( slider, SIGNAL(valueChanged( int ) ), viewer, SLOT( value( int ) ) ); QObject::connect( button, SIGNAL(clicked() ), viewer, SLOT( add_key() ) ); QObject::connect( slider, SIGNAL(valueChanged( int ) ), viewer, SLOT( updateGL( ) ) ); lay->addWidget(viewer); lay->addWidget(slider); lay->addWidget(button); wid->setLayout( lay ); wid->show(); return app.exec(); }
MyWidget::MyWidget(QWidget *parent) : QWidget(parent) { QPushButton *quit = new QPushButton(tr("Quit")); quit->setFont(QFont("Times", 18, QFont::Bold)); QLCDNumber *lcd = new QLCDNumber(2); lcd->setSegmentStyle(QLCDNumber::Filled); QSlider *slider = new QSlider(Qt::Horizontal); slider->setRange(0, 99); slider->setValue(0); connect(quit, SIGNAL(clicked()), qApp, SLOT(quit())); connect(slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int))); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(quit); layout->addWidget(lcd); layout->addWidget(slider); setLayout(layout); }
bool MainWindow::eventFilter(QObject * /*obj*/, QEvent *event) { if (event->type() == QEvent::Wheel) { QWheelEvent *wheelEvent = (QWheelEvent*)event; QSlider *slider = nullptr; if (QApplication::keyboardModifiers() & Qt::ControlModifier) { slider = dock->zoomLevelSlider; } else if (QApplication::keyboardModifiers() & Qt::ShiftModifier) { slider = dock->fftSizeSlider; } if (slider != nullptr) { if (wheelEvent->angleDelta().y() > 0) { slider->setValue(slider->value() + 1); } else if (wheelEvent->angleDelta().y() < 0) { slider->setValue(slider->value() - 1); } return true; } } return false; }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget *window = new QWidget; window->setWindowTitle("Enter Your Age"); QSpinBox *spinBox = new QSpinBox; QSlider *slider = new QSlider(Qt::Horizontal); spinBox->setRange(0, 130); slider->setRange(0, 130); QObject::connect(spinBox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int))); QObject::connect(slider, SIGNAL(valueChanged(int)), spinBox, SLOT(setValue(int))); spinBox->setValue(35); QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(spinBox); layout->addWidget(slider); window->setLayout(layout); window->show(); return app.exec(); }
MultiSlidingValueDialog::MultiSlidingValueDialog(QString text, int defValue, int min, int max, int count, QWidget *parent) : QDialog(parent), mText(text) { QVBoxLayout *vbl = new QVBoxLayout(this); QWidget *widget = new QWidget(this); vbl->addWidget(widget); QFormLayout *fl = new QFormLayout(widget); for (int i = 0; i < count; i++) { QLabel *label = new QLabel(text, this); QSlider *slider = new QSlider(Qt::Horizontal, this); mLabels << label; mSliders << slider; slider->setObjectName(QString::number(i)); slider->setMinimum(min); slider->setMaximum(max); connect(slider, SIGNAL(valueChanged(int)), this, SLOT(updateText(int))); slider->setValue(defValue); updateText(slider->value()); fl->addRow(label, slider); } QDialogButtonBox *dbb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); connect(dbb, SIGNAL(accepted()), this, SLOT(accept())); connect(dbb, SIGNAL(rejected()), this, SLOT(reject())); vbl->addWidget(dbb); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); //Creo objects QWidget *window = new QWidget; QLabel *label = new QLabel("<h3><font color=red>Soy un label</color></h3><u>underline</u><b>bold</b><i>cursivo</i>"); QPushButton *button = new QPushButton("Soy un boton"); QLineEdit *textbox = new QLineEdit(); QCheckBox *cajita = new QCheckBox(); QRadioButton *botoncito = new QRadioButton(); QSpinBox *spinbox = new QSpinBox; QSlider *slider = new QSlider; QHBoxLayout *principal = new QHBoxLayout; QVBoxLayout *layout = new QVBoxLayout; QHBoxLayout *l_botones = new QHBoxLayout; QHBoxLayout *l_barra = new QHBoxLayout; //Seteo parámetros a objetos window->setWindowTitle("Soy un título"); spinbox->setRange(0,130); slider->setRange(0,130); //Conecto acciones QObject::connect(button, SIGNAL(clicked()), &app, SLOT(quit())); QObject::connect(spinbox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int))); QObject::connect(slider, SIGNAL(valueChanged(int)), spinbox, SLOT(setValue(int))); //Agrego objetos al panel principal->addLayout(l_barra); principal->addLayout(layout); l_barra->addWidget(slider); layout->addWidget(label); layout->addWidget(button); layout->addWidget(textbox); layout->addLayout(l_botones); layout->addWidget(spinbox); l_botones->addWidget(cajita); l_botones->addWidget(botoncito); //Inicio window->setLayout(principal); window->show(); return app.exec(); }
void QSoundProcessor::open_volume_dialog() { QDialog dialog; dialog.setWindowTitle(tr("Volume level")); dialog.setFixedSize(160,80); QVBoxLayout Lcenter; QGroupBox GBbox(tr("Set volume level:")); QHBoxLayout layout; QSlider slider; slider.setOrientation(Qt::Horizontal); slider.setRange(1, VOLUME_STEPS); slider.setTickInterval(10); slider.setTickPosition(QSlider::TicksBothSides); QLabel lable(tr("error")); connect(&slider, SIGNAL(valueChanged(int)), &lable, SLOT(setNum(int))); if(pt_audioinput) { slider.setValue( VOLUME_STEPS * pt_audioinput->volume() ); } connect(&slider, SIGNAL(sliderMoved(int)), this, SLOT(set_volume(int))); layout.addWidget(&slider); layout.addWidget(&lable, 2, Qt::AlignRight); GBbox.setLayout(&layout); Lcenter.addWidget(&GBbox); dialog.setLayout(&Lcenter); dialog.exec(); }
void lightweightdialog::drawSliders(int nlights) { for (int slider = 0; slider < sliders.size(); ++slider) { delete sliders[slider]; } sliders.clear(); weights_ = std::vector<float>(nlights); delete slider_layout; slider_layout = new QHBoxLayout(this); nlights_ = nlights; int initial_slider_value = (1/(float)nlights_) * 100; std::vector<float> default_weights; for (auto i = 0; i < nlights; ++i) { default_weights.push_back(1/(float)nlights_); } for (int light = 0; light < nlights_; ++light) { QSlider *slider = new QSlider(); slider->setMinimum(0); slider->setMaximum(100); slider->setValue(initial_slider_value); slider->setObjectName(QString::number(light)); slider->setValue(default_weights[light] * 100); sliders.push_back(slider); slider_layout->addWidget(slider); slider_layout->addSpacing(20); connect(slider, SIGNAL(sliderReleased()), this, SLOT(handleSliderRelease())); // connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(handleSliderChange(int))); } this->adjustSize(); }
int main(int argc, char *argv[]) { QApplication::setGraphicsSystem("raster"); QApplication app(argc, argv); QMainWindow mainWindow; mainWindow.resize(500, 300); mainWindow.setWindowTitle("PS Move API Labs - Sensor Filter"); QWidget centralWidget; QBoxLayout layout(QBoxLayout::LeftToRight); centralWidget.setLayout(&layout); QTimer timer; QSlider slider; layout.addWidget(&slider); slider.setRange(0, 100); MoveGraph moveGraph; layout.addWidget(&moveGraph); mainWindow.setCentralWidget(¢ralWidget); QObject::connect(&timer, SIGNAL(timeout()), &moveGraph, SLOT(readSensors())); QObject::connect(&slider, SIGNAL(valueChanged(int)), &moveGraph, SLOT(setAlpha(int))); slider.setValue(50); moveGraph.setAlpha(50); timer.start(1); mainWindow.show(); return app.exec(); }
// Move Action ThymioMoveAction::ThymioMoveAction( QGraphicsItem *parent ) : ThymioButton(false, 0.2, false, false, parent) { setData(0, "action"); setData(1, "move"); QTransform transMatrix(2.0,0.0,0.0,0.0,2.3,0.0,0.0,0.0,1.0); for(int i=0; i<2; i++) { QSlider *s = new QSlider(Qt::Vertical); s->setRange(-500,500); s->setStyleSheet("QSlider::groove:vertical { width: 14px; border: 2px solid #000000; " "background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #00FF00, stop:0.25 #FFFF00, stop:0.5 #FF0000, stop:0.75 #FFFF00, stop:1 #00FF00 ); }" "QSlider::handle:vertical { " "background: #FFFFFF; " "border: 2px solid #000000; height: 10px; width: 20px; margin: 0px 0; }"); s->setSliderPosition(0); QGraphicsProxyWidget *w = new QGraphicsProxyWidget(this); w->setWidget(s); w->setPos(10+i*200, 15); w->setTransform(transMatrix); sliders.push_back(s); widgets.push_back(w); connect(s, SIGNAL(valueChanged(int)), this, SLOT(valueChangeDetected())); connect(s, SIGNAL(valueChanged(int)), this, SLOT(updateIRButton())); } timer = new QTimeLine(2000); timer->setFrameRange(0, 100); timer->setCurveShape(QTimeLine::LinearCurve); animation = new QGraphicsItemAnimation(this); animation->setItem(thymioBody); animation->setTimeLine(timer); thymioBody->setTransformOriginPoint(0,-14);//(pt[1]+pt[0]) == 0 ? 0 : (abs(pt[1])-abs(pt[0]))/(abs(pt[1])+abs(pt[0]))*22.2,-25); }
QSlider *Window::createSliderXY() { QSlider *slider = new QSlider(Qt::Vertical); slider->setRange(0, /*glWidget->n*/255); slider->setValue(100); slider->setSingleStep(16); slider->setPageStep(16); slider->setTickInterval(10); slider->setTickPosition(QSlider::TicksRight); return slider; }