Keine Beschreibung

noscrollspinbox.cpp 378B

12345678910111213141516
  1. #include "noscrollspinbox.h"
  2. NoScrollSpinBox::NoScrollSpinBox(QWidget *parent)
  3. : QSpinBox(parent)
  4. {
  5. // Don't let scrolling hijack focus.
  6. setFocusPolicy(Qt::StrongFocus);
  7. }
  8. void NoScrollSpinBox::wheelEvent(QWheelEvent *event)
  9. {
  10. // Only allow scrolling to modify contents when it explicitly has focus.
  11. if (hasFocus())
  12. QSpinBox::wheelEvent(event);
  13. }