I need to set spinbox value to one of 1, 10, 100, 1000, 10000 if value changed by spinbox buttons or mouse wheel or up or down keys. But if value changed by keyboard I need other behavior.
Here is my code for buttons, mouse wheel, up and down keys.
void Dlg::onValueChanged(int value)
{
if (value > _value)
value = (value - 1) * 10;
value = log10(value);
value = _Pow_int(10, value);
_ui->spinBoxs->setValue(_value = value);
}
How can I make other behavior for value changing by keyboard?
In this case I think you will have create your custom spinbox derived from
QSpinBox
. And you will need to reimplement at least the following functions:with your specification.