26 lines
585 B
C++
26 lines
585 B
C++
#include "noscrollspinbox.h"
|
|
|
|
unsigned actionId = 0xffff;
|
|
|
|
NoScrollSpinBox::NoScrollSpinBox(QWidget *parent)
|
|
: QSpinBox(parent)
|
|
{
|
|
// Don't let scrolling hijack focus.
|
|
setFocusPolicy(Qt::StrongFocus);
|
|
}
|
|
|
|
void NoScrollSpinBox::wheelEvent(QWheelEvent *event)
|
|
{
|
|
// Only allow scrolling to modify contents when it explicitly has focus.
|
|
if (hasFocus())
|
|
QSpinBox::wheelEvent(event);
|
|
}
|
|
|
|
void NoScrollSpinBox::focusOutEvent(QFocusEvent *event) {
|
|
actionId++;
|
|
QSpinBox::focusOutEvent(event);
|
|
}
|
|
|
|
unsigned NoScrollSpinBox::getActionId() {
|
|
return actionId;
|
|
}
|