PDA

View Full Version : set the range in textedit



sangee
10th August 2012, 08:21
How to set the range ie,(115.0 to 200.0) in textedit?

BalaQT
10th August 2012, 08:51
hi,
u can use spin box for setting the range.


QSpinBox *sp = new QSpinBox;
sp->setRange(115.0,200.0);

why u r using text edit?

for reading the value from spinBox


sp->value();

for setting the value in spinbox
sp->setValue();

Hope it helps
Bala

Zlatomir
10th August 2012, 09:03
Or if you really need text edit use QLineEdit and setValidator (http://qt-project.org/doc/qt-4.8/qlineedit.html#setValidator), also see QDoubleValidator (http://qt-project.org/doc/qt-4.8/qdoublevalidator.html)

LE: a small issue with BalaQT's answer is that you need QDoubleSpinBox (http://qt-project.org/doc/qt-4.8/qdoublespinbox.html) class QSpinBox uses only int's

BalaQT
21st August 2012, 08:37
LE: a small issue with BalaQT's answer is that you need QDoubleSpinBox class QSpinBox uses only int's
:) thanks zlatomir for correcting me
Bala