View Full Version : QValidator problem
zgulser
20th April 2009, 07:30
Hi,
myLineEdit->setValidator( new QDoubleValidator(0.0, 512.0, 1, this));
when I do the above, firstly it doesn't to the correct range check ( i.e. it accepts 717) and secondly I can't edit myLineEdit again after I pressed enter.
Any ideas?
Thanks in advance
grantbj74
18th October 2011, 07:49
Old topic, but I have a similar issue. I did a lot of trolling but couldn't find anything.
With mine it allows you to type 9.00
I think your supposed to use QValidate::fixUp(), but I am unsure on how to do this.
QWidget* StringDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &,const QModelIndex &) const
{
QLineEdit *editor = new QLineEdit(parent);
QDoubleValidator* val = new QDoubleValidator(editor);
val->setNotation(QDoubleValidator::StandardNotation);
val->setRange(0, 5.1, 2);
editor->setValidator(val);
return editor;
}
Anyone got some tips please?
grantbj74
19th October 2011, 04:24
I stumbled across QDoubleSpinBox, that fixed it for me.
QWidget* StringDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &,const QModelIndex &) const
{
QDoubleSpinBox *dspin = new QDoubleSpinBox(parent);
dspin->setRange(0, 5.1);
return dspin;
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.