No Description

noscrollcombobox.cpp 383B

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