PDA

View Full Version : QSpinbox value changes only by double click on up/down button



PradeepP
11th December 2019, 08:38
My Spinbox changes value only by double clicking up/down button. I want o change this to value change on single click. Can anybody help me on how to do this please?

Added after 1 41 minutes:


My Spinbox changes value only by double clicking up/down button. I want o change this to value change on single click. Can anybody help me on how to do this please?

Further information: I noticed that eventfilter() function of window on which spinbox is used is actually preventing it to increment/decrement values on single click. I want to display soft keyboard and set focus on clicked spinbox and hence evenfilter() is implemented. The code snippet is as below:
if (event->type() == QEvent::MouseButtonPress) {
if (object->objectName() == "brightSpinbox" ) {
show_keyboard();
ui->brightSpinbox->setFocus();
return true;
}
return false;
}
I want to have this functionality in place as well as increment/decrement values of spinbox on single click. Can anybody please help?

d_stranz
11th December 2019, 18:33
Your method is returning "true" when it finds a MouseButtonPress event for your spin box. This means the event is prevented from reaching the spin box for its normal handling (eg. an up/down click). Return false instead so the event gets passed along to the spin box.