summaryrefslogtreecommitdiffstats
path: root/examples/widgets/widgets
diff options
context:
space:
mode:
authorOto Magaldadze <omagaldadze@gmail.com>2013-09-17 14:02:49 +0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-29 12:12:16 +0100
commite913972d5268a2b1e5bfc12a0a72e4811e764d86 (patch)
tree93edbd28c651e9862fc4fd6b681d7a8d62f625bc /examples/widgets/widgets
parentfc5d07cee3c2d0f90badd24ddab0b220492f474f (diff)
added QAbstractSpinBox::setGroupSeparatorShown function.
[ChangeLog][QtWidgets][QAbstractSpinBox] QTBUG-5142 - This will allow a group (thousand) separator to be shown in QSpinBox and QDoubleSpinBox widgets. Task-number: QTBUG-5142 Change-Id: I2e23f5f83c93bb092a2dbd784e06d17d40d42909 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'examples/widgets/widgets')
-rw-r--r--examples/widgets/widgets/spinboxes/window.cpp25
-rw-r--r--examples/widgets/widgets/spinboxes/window.h3
2 files changed, 28 insertions, 0 deletions
diff --git a/examples/widgets/widgets/spinboxes/window.cpp b/examples/widgets/widgets/spinboxes/window.cpp
index acce642ec6..7c2f6e45bc 100644
--- a/examples/widgets/widgets/spinboxes/window.cpp
+++ b/examples/widgets/widgets/spinboxes/window.cpp
@@ -94,6 +94,16 @@ void Window::createSpinBoxes()
priceSpinBox->setValue(99);
//! [4] //! [5]
+ groupSeparatorSpinBox = new QSpinBox;
+ groupSeparatorSpinBox->setRange(-99999999, 99999999);
+ groupSeparatorSpinBox->setValue(1000);
+ groupSeparatorSpinBox->setGroupSeparatorShown(true);
+ QCheckBox *groupSeparatorChkBox = new QCheckBox;
+ groupSeparatorChkBox->setText(tr("Show group separator"));
+ groupSeparatorChkBox->setChecked(true);
+ connect(groupSeparatorChkBox, &QCheckBox::toggled, groupSeparatorSpinBox,
+ &QSpinBox::setGroupSeparatorShown);
+
QLabel *hexLabel = new QLabel(tr("Enter a value between "
"%1 and %2:").arg('-' + QString::number(31, 16)).arg(QString::number(31, 16)));
QSpinBox *hexSpinBox = new QSpinBox;
@@ -111,6 +121,8 @@ void Window::createSpinBoxes()
spinBoxLayout->addWidget(priceSpinBox);
spinBoxLayout->addWidget(hexLabel);
spinBoxLayout->addWidget(hexSpinBox);
+ spinBoxLayout->addWidget(groupSeparatorChkBox);
+ spinBoxLayout->addWidget(groupSeparatorSpinBox);
spinBoxesGroup->setLayout(spinBoxLayout);
}
//! [5]
@@ -237,6 +249,17 @@ void Window::createDoubleSpinBoxes()
//! [17]
this, SLOT(changePrecision(int)));
+ groupSeparatorSpinBox_d = new QDoubleSpinBox;
+ groupSeparatorSpinBox_d->setRange(-99999999, 99999999);
+ groupSeparatorSpinBox_d->setDecimals(2);
+ groupSeparatorSpinBox_d->setValue(1000.00);
+ groupSeparatorSpinBox_d->setGroupSeparatorShown(true);
+ QCheckBox *groupSeparatorChkBox = new QCheckBox;
+ groupSeparatorChkBox->setText(tr("Show group separator"));
+ groupSeparatorChkBox->setChecked(true);
+ connect(groupSeparatorChkBox, &QCheckBox::toggled, groupSeparatorSpinBox_d,
+ &QDoubleSpinBox::setGroupSeparatorShown);
+
//! [18]
QVBoxLayout *spinBoxLayout = new QVBoxLayout;
spinBoxLayout->addWidget(precisionLabel);
@@ -247,6 +270,8 @@ void Window::createDoubleSpinBoxes()
spinBoxLayout->addWidget(scaleSpinBox);
spinBoxLayout->addWidget(priceLabel);
spinBoxLayout->addWidget(priceSpinBox);
+ spinBoxLayout->addWidget(groupSeparatorChkBox);
+ spinBoxLayout->addWidget(groupSeparatorSpinBox_d);
doubleSpinBoxesGroup->setLayout(spinBoxLayout);
}
//! [18]
diff --git a/examples/widgets/widgets/spinboxes/window.h b/examples/widgets/widgets/spinboxes/window.h
index ef7af04f59..32622c2c24 100644
--- a/examples/widgets/widgets/spinboxes/window.h
+++ b/examples/widgets/widgets/spinboxes/window.h
@@ -45,6 +45,7 @@
QT_BEGIN_NAMESPACE
class QDateTimeEdit;
+class QSpinBox;
class QDoubleSpinBox;
class QGroupBox;
class QLabel;
@@ -75,6 +76,8 @@ private:
QGroupBox *editsGroup;
QGroupBox *doubleSpinBoxesGroup;
QLabel *meetingLabel;
+ QSpinBox *groupSeparatorSpinBox;
+ QDoubleSpinBox *groupSeparatorSpinBox_d;
};
//! [0]