Skip to content
Permalink
Browse files

[processing] Use QgsDoubleSpinBox instead of QSpinBox

Allows for simple calculations in spin box, adds a reset control
to reset widget to default value
  • Loading branch information
nyalldawson committed Nov 18, 2015
1 parent 86231d7 commit 53aa583da002ec48c8c48ae76e7fcc633ca7101e
@@ -32,8 +32,9 @@
from PyQt4.QtCore import Qt, QEvent, QPyNullVariant
from PyQt4.QtGui import (QFileDialog, QDialog, QIcon, QStyle,
QStandardItemModel, QStandardItem, QMessageBox, QStyledItemDelegate,
QLineEdit, QSpinBox, QDoubleSpinBox, QWidget, QToolButton, QHBoxLayout,
QLineEdit, QWidget, QToolButton, QHBoxLayout,
QComboBox)
from qgis.gui import QgsDoubleSpinBox, QgsSpinBox

from processing.core.ProcessingConfig import ProcessingConfig, Setting
from processing.core.Processing import Processing
@@ -198,11 +199,11 @@ def createEditor(
else:
value = self.convertValue(index.model().data(index, Qt.EditRole))
if isinstance(value, (int, long)):
spnBox = QSpinBox(parent)
spnBox = QgsSpinBox(parent)
spnBox.setRange(-999999999, 999999999)
return spnBox
elif isinstance(value, float):
spnBox = QDoubleSpinBox(parent)
spnBox = QgsDoubleSpinBox(parent)
spnBox.setRange(-999999999.999999, 999999999.999999)
spnBox.setDecimals(6)
return spnBox
@@ -61,6 +61,7 @@ def __init__(self, number, minimum, maximum, isInteger):
self.spnValue.setMinimum(-99999999)

self.spnValue.setValue(float(number))
self.spnValue.setClearValue(float(number))

self.btnCalc.clicked.connect(self.showNumberInputDialog)

@@ -21,7 +21,7 @@
<number>0</number>
</property>
<item>
<widget class="QDoubleSpinBox" name="spnValue">
<widget class="QgsDoubleSpinBox" name="spnValue">
<property name="decimals">
<number>6</number>
</property>
@@ -45,6 +45,14 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgis.gui</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

0 comments on commit 53aa583

Please sign in to comment.
You can’t perform that action at this time.