void RenderingItem::setValue(QVariant new_value) { if(value == new_value) return; value = new_value; if(!GUI) return; if(QString(GUI->metaObject()->className()) == "QSlider") { QSlider *slider = (QSlider*)GUI; if(slider->maximum() == 10) // int slider->setValue(new_value.toInt()); else slider->setValue(new_value.toFloat()*5.0); } if(QString(GUI->metaObject()->className()) == "QColorToolButton") { ((QColorToolButton*)GUI)->setColor(new_value.toInt()); } if(QString(GUI->metaObject()->className()) == "QDoubleSpinBox") { ((QDoubleSpinBox*)GUI)->setValue(new_value.toFloat()); } if(QString(GUI->metaObject()->className()) == "QSpinBox") { ((QSpinBox*)GUI)->setValue(new_value.toInt()); } if(QString(GUI->metaObject()->className()) == "QComboBox") { ((QComboBox*)GUI)->setCurrentIndex(new_value.toInt()); } }
/** Sets the minimum/maximum value of the channel 0 to seven output sliders. Have to do it here because setMinimum is not a slot. One added trick: if the slider is at either its max or its min when the value is changed, then keep it on the max/min. */ void ConfigServoWidget::setChOutRange() { QSpinBox *spinbox = (QSpinBox*)QObject::sender(); int index = outMin.indexOf(spinbox); // This is the channel number if (index < 0) index = outMax.indexOf(spinbox); // We can't know if the signal came from min or max QSlider *slider = outSliders[index]; int oldMini = slider->minimum(); int oldMaxi = slider->maximum(); if (outMin[index]->value()<outMax[index]->value()) { slider->setRange(outMin[index]->value(), outMax[index]->value()); reversals[index]->setChecked(false); } else { slider->setRange(outMax[index]->value(), outMin[index]->value()); reversals[index]->setChecked(true); } if (slider->value() == oldMini) slider->setValue(slider->minimum()); // if (slider->value() == oldMaxi) // slider->setValue(slider->maximum()); // this can be dangerous if it happens to be controlling a motor at the time! }
void SettingsWindow::setLogoRatio(int sliderValue) { QSlider *slider = reinterpret_cast<QSlider *>(sender()); qreal steps = slider->maximum() - slider->minimum(); qreal ratio = sliderValue / steps; _settings->setLogoSizeRatio(ratio); }
void checkLimits(HI::GUITestOpStatus &os, int minVal, int maxVal){ QSlider* thresholdSlider = qobject_cast<QSlider*>(GTWidget::findWidget(os, "thresholdSlider")); CHECK_SET_ERR(thresholdSlider != NULL, "thresholdSlider not found"); int actualSliderMin = thresholdSlider->minimum(); int actualSliderMax = thresholdSlider->maximum(); CHECK_SET_ERR(actualSliderMin == minVal, QString("wrong minimal value for slider. Expected: %1, actual: %2").arg(minVal).arg(actualSliderMin)); CHECK_SET_ERR(actualSliderMax == maxVal, QString("wrong maximim value for slider. Expected: %1, actual: %2").arg(maxVal).arg(actualSliderMin)); QSpinBox* thresholdSpinBox = qobject_cast<QSpinBox*>(GTWidget::findWidget(os, "thresholdSpinBox")); CHECK_SET_ERR(thresholdSpinBox != NULL, "thresholdSpin not found"); int actualSpinMin = thresholdSpinBox->minimum(); int actualSpinMax = thresholdSpinBox->maximum(); CHECK_SET_ERR(actualSpinMin == minVal, QString("wrong minimal value for spin. Expected: %1, actual: %2").arg(minVal).arg(actualSpinMin)); CHECK_SET_ERR(actualSpinMax == maxVal, QString("wrong maximim value for spin. Expected: %1, actual: %2").arg(maxVal).arg(actualSpinMin)); }