PDA

View Full Version : QLineEdit and setInputMask



mr_kazoodle
22nd January 2011, 19:59
Hi,

When I run my program the default text displayed in the field is a zero with 6 spaces behind it instead of "0" (a zero without spaces behind it).(I didn't encounter any errors of any kind)

What do I need to do to get rid of those spaces?

QLineEdit *qleobject = new QLineEdit(this);
qleobject->setInputMask("0000000");
qleobject->setText("0");
qleobject->setAlignment(Qt::AlignRight);
http://img255.imageshack.us/img255/7128/screenshotvo.png (http://img255.imageshack.us/i/screenshotvo.png/)
Uploaded with ImageShack.us (http://imageshack.us)

high_flyer
22nd January 2011, 20:41
I would consider using QIntValidator instead.

mr_kazoodle
22nd January 2011, 22:38
Thank you very much for helping me.
This is the result:

QLineEdit *qleobject = new QLineEdit(this);
qleobject->setText("0");
qleobject->setAlignment(Qt::AlignRight);

QIntValidator *val = new QIntValidator(0,2147483647,this);
qleobject->setValidator(val);

qApp->connect(//more code...
Edit: Where do I mark the thread as solved, I can't seem to find it? (I'm sorry for the trouble)

high_flyer
23rd January 2011, 15:47
Edit: Where do I mark the thread as solved, I can't seem to find it?
No real need to, the thread just ends, and who ever reads it can see it was resolved or not.
But you can edit the title if you like (some people do).