Skip to content
Snippets Groups Projects
Commit 152cfa4b authored by Wenzel Jakob's avatar Wenzel Jakob
Browse files

rendersettingsdlg.cpp: ignore mouse scroll events in spin boxes

parent 11c5ef74
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,24 @@
#include <mitsuba/core/plugin.h>
#include <mitsuba/core/fresolver.h>
class BetterSpinBox : public QSpinBox {
public:
BetterSpinBox(QWidget *parent) : QSpinBox(parent) {
setFrame(false);
setFocusPolicy(Qt::StrongFocus);
setMinimum(-1);
setMaximum(INT_MAX);
}
bool event(QEvent *event) {
if(event->type() == QEvent::Wheel) {
event->ignore();
return false;
}
return QSpinBox::event(event);
}
};
class BetterDoubleSpinBox : public QDoubleSpinBox {
public:
BetterDoubleSpinBox(QWidget *parent) : QDoubleSpinBox(parent) {
......@@ -28,6 +46,7 @@ public:
setMinimum(-std::numeric_limits<double>::max());
setMaximum(std::numeric_limits<double>::max());
setFrame(false);
setFocusPolicy(Qt::StrongFocus);
}
void morphNumericString(char *s) const {
......@@ -47,6 +66,14 @@ public:
morphNumericString(tmp);
return QString::fromAscii(tmp);
}
bool event(QEvent *event) {
if(event->type() == QEvent::Wheel) {
event->ignore();
return false;
}
return QDoubleSpinBox::event(event);
}
};
/* ====================== Some helper routines ====================== */
......@@ -566,7 +593,9 @@ QWidget *PropertyDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
}
QWidget *widget;
if (index.data().type() == QVariant::Double)
if (index.data().type() == QVariant::Int)
widget = new BetterSpinBox(parent);
else if (index.data().type() == QVariant::Double)
widget = new BetterDoubleSpinBox(parent);
else
widget = QStyledItemDelegate::createEditor(parent, option, index);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment