本文整理汇总了C++中SpinBox::setValue方法的典型用法代码示例。如果您正苦于以下问题:C++ SpinBox::setValue方法的具体用法?C++ SpinBox::setValue怎么用?C++ SpinBox::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpinBox
的用法示例。
在下文中一共展示了SpinBox::setValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KinematicsBarSetupDialog
KinematicsBarSetupDialog() {
setWindowTitle(_("Kinematics Operation Setup"));
QVBoxLayout* vbox = new QVBoxLayout();
setLayout(vbox);
QHBoxLayout* hbox = new QHBoxLayout();
hbox->addWidget(new QLabel(_("Snap thresholds:")));
hbox->addSpacing(10);
hbox->addWidget(new QLabel(_("distance")));
snapDistanceSpin.setAlignment(Qt::AlignCenter);
snapDistanceSpin.setDecimals(3);
snapDistanceSpin.setRange(0.0, 0.999);
snapDistanceSpin.setSingleStep(0.001);
snapDistanceSpin.setValue(0.025);
hbox->addWidget(&snapDistanceSpin);
hbox->addWidget(new QLabel(_("[m]")));
hbox->addSpacing(5);
hbox->addWidget(new QLabel(_("angle")));
snapAngleSpin.setAlignment(Qt::AlignCenter);
snapAngleSpin.setRange(0, 90);
snapAngleSpin.setValue(30);
hbox->addWidget(&snapAngleSpin);
hbox->addWidget(new QLabel(_("[deg]")));
vbox->addLayout(hbox);
hbox = new QHBoxLayout();
hbox->addWidget(new QLabel(_("Penetration block depth")));
penetrationBlockDepthSpin.setAlignment(Qt::AlignCenter);
penetrationBlockDepthSpin.setDecimals(4);
penetrationBlockDepthSpin.setRange(0.0, 0.0099);
penetrationBlockDepthSpin.setSingleStep(0.0001);
penetrationBlockDepthSpin.setValue(0.0005);
hbox->addWidget(&penetrationBlockDepthSpin);
hbox->addWidget(new QLabel(_("[m]")));
vbox->addLayout(hbox);
hbox = new QHBoxLayout();
lazyCollisionDetectionModeCheck.setText(_("Lazy collision detection mode"));
lazyCollisionDetectionModeCheck.setChecked(true);
hbox->addWidget(&lazyCollisionDetectionModeCheck);
vbox->addLayout(hbox);
hbox = new QHBoxLayout();
okButton.setText(_("OK"));
okButton.setDefault(true);
hbox->addWidget(&okButton);
vbox->addLayout(hbox);
}
示例2: dialog
void
KnobGuiColor::showColorDialog()
{
QColorDialog dialog( _colorLabel->parentWidget() );
dialog.setOption(QColorDialog::DontUseNativeDialog);
KnobColorPtr knob = _knob.lock();
const int nDims = knob->getDimension();
double curR = knob->getValue(0);
_lastColor[0] = curR;
double curG = curR;
double curB = curR;
double curA = 1.;
if (nDims > 1) {
curG = knob->getValue(1);
_lastColor[1] = curG;
curB = knob->getValue(2);
_lastColor[2] = curB;
}
if (nDims > 3) {
dialog.setOption(QColorDialog::ShowAlphaChannel);
curA = knob->getValue(3);
_lastColor[3] = curA;
}
bool isSimple = _useSimplifiedUI;
QColor curColor;
curColor.setRgbF( Image::clamp<qreal>(isSimple ? curR : Color::to_func_srgb(curR), 0., 1.),
Image::clamp<qreal>(isSimple ? curG : Color::to_func_srgb(curG), 0., 1.),
Image::clamp<qreal>(isSimple ? curB : Color::to_func_srgb(curB), 0., 1.),
Image::clamp<qreal>(curA, 0., 1.) );
dialog.setCurrentColor(curColor);
QObject::connect( &dialog, SIGNAL(currentColorChanged(QColor)), this, SLOT(onDialogCurrentColorChanged(QColor)) );
if ( !dialog.exec() ) {
if (nDims == 3) {
knob->setValues(_lastColor[0], _lastColor[1], _lastColor[2], ViewSpec::all(), eValueChangedReasonNatronGuiEdited);
} else if (nDims == 4) {
knob->setValues(_lastColor[0], _lastColor[1], _lastColor[2], _lastColor[3], ViewSpec::all(), eValueChangedReasonNatronGuiEdited);
} else if (nDims == 1) {
knob->setValue(_lastColor[0], ViewSpec::all(), 0, eValueChangedReasonNatronGuiEdited);
}
} else {
QColor userColor = dialog.currentColor();
std::vector<double> color(4);
color[0] = isSimple ? userColor.redF() : Color::from_func_srgb( userColor.redF() );
color[1] = isSimple ? userColor.greenF() : Color::from_func_srgb( userColor.greenF() );
color[2] = isSimple ? userColor.blueF() : Color::from_func_srgb( userColor.blueF() );
color[3] = userColor.alphaF();
for (int i = 0; i < 3; ++i) {
SpinBox* sb = 0;
getSpinBox(i, &sb);
assert(sb);
sb->setValue(color[i]);
}
// Refresh the last value so that the undo command retrieves the value that was prior to opening the dialog
if (nDims == 3) {
knob->setValues(_lastColor[0], _lastColor[1], _lastColor[2], ViewSpec::all(), eValueChangedReasonUserEdited);
} else if (nDims == 4) {
knob->setValues(_lastColor[0], _lastColor[1], _lastColor[2], _lastColor[3], ViewSpec::all(), eValueChangedReasonUserEdited);
} else if (nDims == 1) {
knob->setValue(_lastColor[0], ViewSpec::all(), 0, eValueChangedReasonUserEdited);
}
onSpinBoxValueChanged();
}
if ( getGui() ) {
getGui()->setDraftRenderEnabled(false);
}
//knob->evaluateValueChange(0, knob->getCurrentTime(), ViewIdx(0), eValueChangedReasonNatronGuiEdited);
} // showColorDialog
示例3: dialog
void
KnobGuiColor::showColorDialog()
{
QColorDialog dialog( _colorLabel->parentWidget() );
dialog.setOption(QColorDialog::DontUseNativeDialog);
KnobColorPtr knob = _knob.lock();
if (!knob) {
return;
}
const int nDims = knob->getNDimensions();
ViewIdx view = getView();
double curR = knob->getValue(DimIdx(0), view, false /*clampToMinmax*/);
_lastColor.resize(nDims);
_lastColor[0] = curR;
double curG = curR;
double curB = curR;
double curA = 1.;
if (nDims > 1) {
curG = knob->getValue(DimIdx(1), view, false /*clampToMinmax*/);
_lastColor[1] = curG;
curB = knob->getValue(DimIdx(2), view, false /*clampToMinmax*/);
_lastColor[2] = curB;
}
if (nDims > 3) {
dialog.setOption(QColorDialog::ShowAlphaChannel);
curA = knob->getValue(DimIdx(3), view, false /*clampToMinmax*/);
_lastColor[3] = curA;
}
convertFromInternalToUIColorspace(&curR, &curG, &curB);
QColor curColor;
curColor.setRgbF( Image::clamp<qreal>(curR, 0., 1.),
Image::clamp<qreal>(curG, 0., 1.),
Image::clamp<qreal>(curB, 0., 1.),
Image::clamp<qreal>(curA, 0., 1.) );
dialog.setCurrentColor(curColor);
QObject::connect( &dialog, SIGNAL(currentColorChanged(QColor)), this, SLOT(onDialogCurrentColorChanged(QColor)) );
if ( !dialog.exec() ) {
knob->setValueAcrossDimensions(_lastColor, DimIdx(0), view, eValueChangedReasonUserEdited);
} else {
QColor userColor = dialog.currentColor();
std::vector<double> color(nDims);
color[0] = userColor.redF();
convertFromUIToInternalColorspace(&color[0]);
if (nDims > 1) {
color[1] = userColor.greenF();
convertFromUIToInternalColorspace(&color[1]);
}
if (nDims > 2) {
color[2] = userColor.blueF();
convertFromUIToInternalColorspace(&color[2]);
}
if (nDims > 3) {
color[3] = userColor.alphaF();
}
for (int i = 0; i < 3; ++i) {
SpinBox* sb = 0;
getSpinBox(DimIdx(i), &sb);
if (sb) {
sb->setValue(color[i]);
}
}
std::vector<double> oldColor(nDims);
for (int i = 0; i < nDims; ++i) {
oldColor[i] = _lastColor[i];
}
KnobGuiPtr knobUI = getKnobGui();
knobUI->pushUndoCommand( new KnobUndoCommand<double>(knob, oldColor, color, getView()) );
}
KnobGuiPtr knobUI = getKnobGui();
if ( knobUI->getGui() ) {
knobUI->getGui()->setDraftRenderEnabled(false);
}
} // showColorDialog