本文整理汇总了C++中singleStep函数的典型用法代码示例。如果您正苦于以下问题:C++ singleStep函数的具体用法?C++ singleStep怎么用?C++ singleStep使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了singleStep函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: switch
void IntValueEditor::keyPressEvent(QKeyEvent* e)
{
switch (e->key())
{
case Qt::Key_BracketLeft:
setSingleStep((int)(singleStep() * 10.0));
QSettings().setValue(QString("intvalueeditor/%1/singlestep").arg(objectName()), singleStep());
break;
case Qt::Key_BracketRight:
setSingleStep(qMax((int)(default_step * 0.10), 1));
QSettings().setValue(QString("intvalueeditor/%1/singlestep").arg(objectName()), singleStep());
break;
case Qt::Key_Return:
QSpinBox::keyPressEvent(e);
emit undoStateSignal();
break;
case Qt::Key_Backslash:
WheelValueEditor::WHEEL_EVENTS_ENABLED
= ! WheelValueEditor::WHEEL_EVENTS_ENABLED;
break;
default:
QSpinBox::keyPressEvent(e);
}
}
开发者ID:ShadowKyogre,项目名称:qosmic,代码行数:28,代码来源:intvalueeditor.cpp
示例2: lineEdit
void SliderDoubleSpinBox::mousePressEvent(QMouseEvent * event)
{
if (event->buttons() & Qt::LeftButton) {
QStyleOptionSpinBox spinOpts = d->spinBoxOptions();
// mouse in progress area?
if (d->progressRect(spinOpts).contains(event->pos())
&& ! lineEdit()->isVisible())
{
setValue(d->valueForX(event->pos().x()));
}
// mouse over up-button?
else if (d->upButtonRect(spinOpts).contains(event->pos())) {
setValue(value() + singleStep());
d->pressedInButton = true;
}
// mouse over down-button?
else if (d->downButtonRect(spinOpts).contains(event->pos())) {
setValue(value() - singleStep());
d->pressedInButton = true;
} else {
// whatever this mouse press is, just pass it on
QDoubleSpinBox::mousePressEvent(event);
}
} else if (event->buttons() & Qt::RightButton) {
// right now, RMB switches into line edit mode
d->showLineEdit();
}
}
开发者ID:KDE,项目名称:tikzkit,代码行数:28,代码来源:SliderDoubleSpinBox.cpp
示例3: pow
void ModQDoubleSpinBox::stepBy(int steps)
{
double cpValue = 0, crValue = 0, newValue = 0; double delta = 0;
if (_discreteValuesMode)
{
// Get current round value:
crValue = pow(10,-decimals()) * round( value()*pow(10,decimals()) );
if (singleStep() < pow(10, -decimals()))
{
// Calculate new value:
newValue = crValue + (steps * pow(10, -decimals()));
newValue = roundToNextDiscreteValue( newValue );
}
else
{
// Get current precise value:
cpValue = roundToNextDiscreteValue( value() );
// Correct nr of steps (if necessary):
if (steps > 0)
delta = cpValue - crValue;
else // < 0 (= 0 ???)
delta = crValue - cpValue;
if (delta >= (pow(10, -decimals()) - _precCorrVal))
steps -= steps/abs(steps);
// Calculate new value:
newValue = cpValue + (steps * singleStep());
}
// Set new value (automatic round to decimals):
QDoubleSpinBox::setValue( newValue );
}
else
QDoubleSpinBox::stepBy(steps);
}
开发者ID:Leipipirs,项目名称:FreeSSM,代码行数:33,代码来源:CUcontent_Adjustments.cpp
示例4: minimum
//! A size hint
QSize QwtCounter::sizeHint() const
{
QString tmp;
int w = tmp.setNum( minimum() ).length();
int w1 = tmp.setNum( maximum() ).length();
if ( w1 > w )
w = w1;
w1 = tmp.setNum( minimum() + singleStep() ).length();
if ( w1 > w )
w = w1;
w1 = tmp.setNum( maximum() - singleStep() ).length();
if ( w1 > w )
w = w1;
tmp.fill( '9', w );
QFontMetrics fm( d_data->valueEdit->font() );
w = fm.width( tmp ) + 2;
if ( d_data->valueEdit->hasFrame() )
w += 2 * style()->pixelMetric( QStyle::PM_DefaultFrameWidth );
// Now we replace default sizeHint contribution of d_data->valueEdit by
// what we really need.
w += QWidget::sizeHint().width() - d_data->valueEdit->sizeHint().width();
const int h = qMin( QWidget::sizeHint().height(),
d_data->valueEdit->minimumSizeHint().height() );
return QSize( w, h );
}
开发者ID:CaptainFalco,项目名称:OpenPilot,代码行数:32,代码来源:qwt_counter.cpp
示例5: logWarn
void IntValueEditor::restoreSettings()
{
if (objectName().isEmpty())
logWarn("IntValueEditor::restoreSettings : nameless object found");
setSingleStep(QSettings().value(
QString("intvalueeditor/%1/singlestep").arg(objectName()), singleStep()).toInt());
default_step = singleStep();
}
开发者ID:ShadowKyogre,项目名称:qosmic,代码行数:10,代码来源:intvalueeditor.cpp
示例6: minimum
void CSliderMultiPos::triggerAction(QAbstractSlider::SliderAction action){
bool noAction = false;
int newPos = 0;
int minPos;
int maxPos;
if( lastPressedIndex==0 ){
minPos = minimum();
}
else{
minPos = handles.at(lastPressedIndex-1).getPosition();
}
if( lastPressedIndex==(nbValues()-1) ){
maxPos = maximum();
}
else{
minPos = handles.at(lastPressedIndex-1).getPosition();
}
blockTracking = true;
switch( action ){
case QAbstractSlider::SliderSingleStepAdd :
newPos = qBound( minPos,minPos + singleStep(),maxPos );
break;
case QAbstractSlider::SliderSingleStepSub :
newPos = qBound( minPos,maxPos - singleStep(),maxPos );
break;
case QAbstractSlider::SliderToMinimum :
newPos = minPos;
break;
case QAbstractSlider::SliderToMaximum :
newPos = maxPos;
break;
case QAbstractSlider::SliderMove :
case QAbstractSlider::SliderNoAction :
noAction = true;
break;
default :
qWarning( "QxtSpanSliderPrivate::triggerAction: Unknown action" );
break;
}
if( noAction ){
// Nothing to do for this action
}
else{
newPos = collisionDetection(newPos);
setCurPosition( lastPressedIndex,newPos );
}
blockTracking = false;
}
开发者ID:anjinkristou,项目名称:SliderMutliPos,代码行数:51,代码来源:CSliderMultiPos.cpp
示例7: logWarn
void DoubleValueEditor::restoreSettings()
{
QSettings settings;
if (objectName().isEmpty())
logWarn("DoubleValueEditor::restoreSettings : nameless object found");
setSingleStep(settings.value(
QString("doublevalueeditor/%1/singlestep").arg(objectName()), singleStep()).toDouble());
setDecimals(settings.value(
QString("doublevalueeditor/%1/decimals").arg(objectName()), decimals()).toInt());
default_step = singleStep();
}
开发者ID:ShadowKyogre,项目名称:qosmic,代码行数:14,代码来源:doublevalueeditor.cpp
示例8: singleStep
/******************************************************************************
* Return the initial adjustment to the value for a shift step up or down, for
* the main (visible) spin box.
* Normally this is a line step, but with a right-to-left language where the
* button functions are reversed, this is a page step.
*/
int SpinBox2::MainSpinBox::shiftStepAdjustment(int oldValue, int shiftStep)
{
if (owner->reverseButtons())
{
// The button pairs have the opposite function from normal.
// Page shift stepping - step up or down to a multiple of the
// shift page increment, leaving unchanged the part of the value
// which is the remainder from the page increment.
if (oldValue >= 0)
oldValue -= oldValue % singleStep();
else
oldValue += (-oldValue) % singleStep();
}
return SpinBox::shiftStepAdjustment(oldValue, shiftStep);
}
开发者ID:KDE,项目名称:kdepim,代码行数:21,代码来源:spinbox2.cpp
示例9: fm
// normal sizeHint doesn't always work right for our case,
// because the min/max/special text aren't necessarily the longest text
QSize MinSecSpinBox::sizeHint() const
{
QSize normal = QSpinBox::sizeHint();
//this first portion copied from QAbstractSpinBox
const QFontMetrics fm(fontMetrics());
int w = 0;
QString s;
s = prefix() + textFromValue(minimum()) + suffix() + QLatin1Char(' ');
s.truncate(18);
w = qMax(w, fm.width(s));
s = prefix() + textFromValue(maximum()) + suffix() + QLatin1Char(' ');
s.truncate(18);
w = qMax(w, fm.width(s));
if (specialValueText().size()) {
s = specialValueText();
w = qMax(w, fm.width(s));
}
w += 2; // cursor blinking space
//new part (see if max - singlestep is longer)
s = textFromValue(maximum()-singleStep()) + QLatin1Char(' ');
int longwidth = fm.width(s) + 2;
int dif = longwidth - w;
if (dif > 0)
normal += QSize(dif, 0);
return normal;
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:31,代码来源:minsecspinbox.cpp
示例10: singleStep
void IntValueEditor::wheelEvent(QWheelEvent* e)
{
if (!QSpinBox::isActiveWindow())
QSpinBox::activateWindow();
QSpinBox::setFocus(Qt::MouseFocusReason);
int step = default_step = singleStep();
if (e->modifiers() & Qt::ShiftModifier)
{
if (step >= 10.0)
setSingleStep(step = (int)(step / 10.0));
}
else if (e->modifiers() & Qt::ControlModifier)
setSingleStep(step = step * 10);
if (e->delta() > 0)
stepUp();
else
stepDown();
if (step != default_step)
setSingleStep(default_step);
if (wheelEventSignal && WheelValueEditor::WHEEL_EVENTS_ENABLED)
emit valueUpdated();
}
开发者ID:ShadowKyogre,项目名称:qosmic,代码行数:26,代码来源:intvalueeditor.cpp
示例11: recalcPrecCorrValue
void ModQDoubleSpinBox::recalcPrecCorrValue()
{
int base_decimals = static_cast<int>(-floor(log10(_DVMbaseValue)));
int singleStep_decimals = static_cast<int>(-floor(log10(singleStep())));
int corrVal_decimals = 1 + std::max(decimals(), std::max(base_decimals, singleStep_decimals));
_precCorrVal = pow(10,-corrVal_decimals);
}
开发者ID:Leipipirs,项目名称:FreeSSM,代码行数:7,代码来源:CUcontent_Adjustments.cpp
示例12: singleStep
void DoubleValueEditor::mouseMoveEvent(QMouseEvent* e)
{
if (e->buttons() & Qt::LeftButton)
{
double dy = e->y() - last_pos.y();
double step = default_step = singleStep();
last_pos = e->posF();
last_press = 0;
if (e->modifiers() & Qt::ShiftModifier)
setSingleStep(step /= 10.0);
else if (e->modifiers() & Qt::ControlModifier)
setSingleStep(step *= 10.0);
if (dy < 0)
{
stepUp();
emit valueUpdated();
}
else if (dy > 0)
{
stepDown();
emit valueUpdated();
}
if (step != default_step)
setSingleStep(default_step);
}
}
开发者ID:ShadowKyogre,项目名称:qosmic,代码行数:29,代码来源:doublevalueeditor.cpp
示例13: singleStep
double ModQDoubleSpinBox::roundToNextDiscreteValue(double inValue)
{
double d_new = 0;
double kcorr = 0;
if (singleStep() != 0)
{
if ((inValue >= 0))
kcorr = _precCorrVal;
if ((inValue < 0))
kcorr = - _precCorrVal;
d_new = singleStep() * round(((inValue - _DVMbaseValue + kcorr) / singleStep())) + _DVMbaseValue;
}
else
d_new = inValue;
return d_new;
}
开发者ID:Leipipirs,项目名称:FreeSSM,代码行数:16,代码来源:CUcontent_Adjustments.cpp
示例14: orientation
// Function copied from qslider.cpp and modified to make it compile
void Slider::initStyleOption_Qt430( QStyleOptionSlider *option ) const
{
if (!option)
return;
option->initFrom( this );
option->subControls = QStyle::SC_None;
option->activeSubControls = QStyle::SC_None;
option->orientation = orientation();
option->maximum = maximum();
option->minimum = minimum();
option->tickPosition = (QSlider::TickPosition) tickPosition();
option->tickInterval = tickInterval();
option->upsideDown = (orientation() == Qt::Horizontal) ?
(invertedAppearance() != (option->direction == Qt::RightToLeft))
: (!invertedAppearance());
option->direction = Qt::LeftToRight; // we use the upsideDown option instead
option->sliderPosition = sliderPosition();
option->sliderValue = value();
option->singleStep = singleStep();
option->pageStep = pageStep();
if (orientation() == Qt::Horizontal)
option->state |= QStyle::State_Horizontal;
}
开发者ID:MarcAntoine-Arnaud,项目名称:QtAV,代码行数:26,代码来源:Slider.cpp
示例15: while
void CalculationThread::run() {
seedmap->resetMatches();
while(singleStep()) {}
}
开发者ID:Sebu,项目名称:epitome,代码行数:8,代码来源:calculationthread.cpp
示例16: value
void VariableDoubleSpinBox::stepBy(int steps)
{
double oldValue = value();
// Default new value
int i = -99;
double newValue = oldValue + singleStep() * steps;
// If a single digit is selected, increment or decrement that digit
if (lineEdit()->hasSelectedText())
{
if (lineEdit()->selectedText().length() == 1)
{
if (lineEdit()->selectedText()[0].isDigit())
{
i = cleanText().length() - lineEdit()->selectionStart();
int j = cleanText().length() - lineEdit()->selectionStart() - decimals();
if (decimals() > 0)
{
j--;
}
if (j >= 0)
{
j--;
}
newValue = oldValue + pow(10.0, j) * steps;
}
}
}
// Check for out of bounds and set the new value
if (newValue < minimum())
{
return;
}
else if (newValue > maximum())
{
return;
}
setValue(newValue);
// For unknown reasons, after the new value is set the selected text changes in unpredictable ways
// Fix it
if (i == -99)
{
lineEdit()->selectAll();
}
else
{
i = cleanText().length() - i;
if (i < 0)
{
i = 0;
}
lineEdit()->setSelection(i, 1);
}
}
开发者ID:cntnly,项目名称:digital-servo,代码行数:57,代码来源:VariableDoubleSpinBox.cpp
示例17: switch
void DoubleValueEditor::keyPressEvent(QKeyEvent* e)
{
switch (e->key())
{
case Qt::Key_BracketLeft:
setSingleStep(singleStep() * 10.0);
QSettings().setValue(QString("doublevalueeditor/%1/singlestep").arg(objectName()), singleStep());
break;
case Qt::Key_BracketRight:
setSingleStep(singleStep() * 0.10);
QSettings().setValue(QString("doublevalueeditor/%1/singlestep").arg(objectName()), singleStep());
break;
case Qt::Key_Return:
QDoubleSpinBox::keyPressEvent(e);
emit undoStateSignal();
break;
case Qt::Key_Backslash:
WheelValueEditor::WHEEL_EVENTS_ENABLED
= ! WheelValueEditor::WHEEL_EVENTS_ENABLED;
break;
case Qt::Key_Plus:
if (e->modifiers() & Qt::ControlModifier)
{
setDecimals(decimals() + 1);
QSettings().setValue(QString("doublevalueeditor/%1/decimals").arg(objectName()), decimals());
}
break;
case Qt::Key_Minus:
if (e->modifiers() & Qt::ControlModifier)
{
setDecimals(qMax(1, decimals() - 1));
QSettings().setValue(QString("doublevalueeditor/%1/decimals").arg(objectName()), decimals());
}
break;
default:
QDoubleSpinBox::keyPressEvent(e);
}
}
开发者ID:ShadowKyogre,项目名称:qosmic,代码行数:44,代码来源:doublevalueeditor.cpp
示例18: main
int main() {
unsigned int step;
initialize();
debugPrint();
for (step = 0; step < M; step++)
singleStep();
debugPrint();
debugGnuplot();
return 0;
}
开发者ID:vasily-golubev,项目名称:stuff,代码行数:10,代码来源:advection.c
示例19: BigNumSpin
QWidget * BigNumDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const
{
BigNumSpin* result = new BigNumSpin(parent);
result->setMinimum(minimum());
result->setMaximum(maximum());
result->setDecimals(decimals());
result->setSingleStep(singleStep());
result->setPrefix(prefix());
result->setSuffix(suffix());
return result;
}
开发者ID:VSRonin,项目名称:CLOModel,代码行数:11,代码来源:BigNumDelegate.cpp
示例20: qt_static_metacall
int QDoubleSpinBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QAbstractSpinBox::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 3)
qt_static_metacall(this, _c, _id, _a);
_id -= 3;
}
#ifndef QT_NO_PROPERTIES
else if (_c == QMetaObject::ReadProperty) {
void *_v = _a[0];
switch (_id) {
case 0: *reinterpret_cast< QString*>(_v) = prefix(); break;
case 1: *reinterpret_cast< QString*>(_v) = suffix(); break;
case 2: *reinterpret_cast< QString*>(_v) = cleanText(); break;
case 3: *reinterpret_cast< int*>(_v) = decimals(); break;
case 4: *reinterpret_cast< double*>(_v) = minimum(); break;
case 5: *reinterpret_cast< double*>(_v) = maximum(); break;
case 6: *reinterpret_cast< double*>(_v) = singleStep(); break;
case 7: *reinterpret_cast< double*>(_v) = value(); break;
}
_id -= 8;
} else if (_c == QMetaObject::WriteProperty) {
void *_v = _a[0];
switch (_id) {
case 0: setPrefix(*reinterpret_cast< QString*>(_v)); break;
case 1: setSuffix(*reinterpret_cast< QString*>(_v)); break;
case 3: setDecimals(*reinterpret_cast< int*>(_v)); break;
case 4: setMinimum(*reinterpret_cast< double*>(_v)); break;
case 5: setMaximum(*reinterpret_cast< double*>(_v)); break;
case 6: setSingleStep(*reinterpret_cast< double*>(_v)); break;
case 7: setValue(*reinterpret_cast< double*>(_v)); break;
}
_id -= 8;
} else if (_c == QMetaObject::ResetProperty) {
_id -= 8;
} else if (_c == QMetaObject::QueryPropertyDesignable) {
_id -= 8;
} else if (_c == QMetaObject::QueryPropertyScriptable) {
_id -= 8;
} else if (_c == QMetaObject::QueryPropertyStored) {
_id -= 8;
} else if (_c == QMetaObject::QueryPropertyEditable) {
_id -= 8;
} else if (_c == QMetaObject::QueryPropertyUser) {
_id -= 8;
}
#endif // QT_NO_PROPERTIES
return _id;
}
开发者ID:unni07,项目名称:RecommenderSystem,代码行数:52,代码来源:moc_qspinbox.cpp
注:本文中的singleStep函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论