How to override the QDoubleSpinbox StepBy function
Unsolved
General and Desktop
-
I am overriding the StepBy function of QDoubleSpinBox
// override to adjust step size void SumDoubleBox::stepBy(int steps) { (steps > 0.0 ? m_stepUp = true : m_stepUp = false); // set the actual step size here double newStep = m_defaultStep; if (QApplication::queryKeyboardModifiers() & Qt::ShiftModifier & Qt::ControlModifier ) newStep *= 0.01; else if (QApplication::queryKeyboardModifiers() & Qt::ShiftModifier) newStep *= 0.1; // be sure to call the base setSingleStep() here, otherwise redundant loop. m_CurrentStep = newStep * steps; QDoubleSpinBox::setSingleStep(newStep); QDoubleSpinBox::stepBy(steps); }
The function works fine but somehow this condition never gets executed
if (QApplication::queryKeyboardModifiers() & Qt::ShiftModifier & Qt::ControlModifier )
when the user presses both shift and Control button the Doublespinbox increments by default value 1
-
@summit said in How to override the QDoubleSpinbox StepBy function:
& Qt::ShiftModifier & Qt::ControlModifier
This is wrong. If you want to check both conditions you have to use 'or' instead binary and