summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews/qitemeditorfactory.cpp
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2012-10-02 13:01:30 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-19 00:44:54 +0200
commitd84f449bcde56fd2df12f82dd2ba2e1f0a4ae7c7 (patch)
tree0d982beb7be025b695e57b707b51eec1e048414c /src/widgets/itemviews/qitemeditorfactory.cpp
parent8bed283f137c14a7be1fb9027eae5eae3ce796be (diff)
Make sure uints remain uints when editing in itemviews.
Task-number: QTBUG-22974 Change-Id: I07428862c4dffc629f868f3010f663eb655922d0 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/widgets/itemviews/qitemeditorfactory.cpp')
-rw-r--r--src/widgets/itemviews/qitemeditorfactory.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp
index 5162a5534c..5f24c3ea1b 100644
--- a/src/widgets/itemviews/qitemeditorfactory.cpp
+++ b/src/widgets/itemviews/qitemeditorfactory.cpp
@@ -73,6 +73,36 @@ public:
#endif // QT_NO_COMBOBOX
+
+#ifndef QT_NO_SPINBOX
+
+class QUIntSpinBox : public QSpinBox
+{
+ Q_OBJECT
+ Q_PROPERTY(uint value READ uintValue WRITE setUIntValue NOTIFY uintValueChanged USER true)
+public:
+ explicit QUIntSpinBox(QWidget *parent = 0)
+ : QSpinBox(parent)
+ {
+ connect(this, SIGNAL(valueChanged(int)), SIGNAL(uintValueChanged()));
+ }
+
+ uint uintValue()
+ {
+ return value();
+ }
+
+ void setUIntValue(uint value_)
+ {
+ return setValue(value_);
+ }
+
+Q_SIGNALS:
+ void uintValueChanged();
+};
+
+#endif // QT_NO_SPINBOX
+
/*!
\class QItemEditorFactory
\brief The QItemEditorFactory class provides widgets for editing item data
@@ -206,8 +236,9 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
#endif
#ifndef QT_NO_SPINBOX
case QVariant::UInt: {
- QSpinBox *sb = new QSpinBox(parent);
+ QSpinBox *sb = new QUIntSpinBox(parent);
sb->setFrame(false);
+ sb->setMinimum(0);
sb->setMaximum(INT_MAX);
return sb; }
case QVariant::Int: {