PDA

View Full Version : line edit mask problem



sudhansu
30th March 2010, 16:01
Hi all
i've a line edit inwhich inputmask is 000.000.000.000. This lineedit will be used as ip input field. But i need that the disatance between "." should be equal. Ive attached a samplecode. plz tel me how to do.

moosa
30th March 2010, 17:23
You used QTextEdit where you should use QLineEdit. QLineEdit is better for this kind of input.
The code you need is:


ui->lineEdit->setInputMask("000.000.000.000;_");

All of this is documented in QT. Read about it in the documentation of QLineEdit.

sudhansu
31st March 2010, 05:54
You used QTextEdit where you should use QLineEdit. QLineEdit is better for this kind of input.
The code you need is:


ui->lineEdit->setInputMask("000.000.000.000;_");

All of this is documented in QT. Read about it in the documentation of QLineEdit.

Oh I'm sorry actually i've used a line edit in my project. but while disaplyaing that line edit i need to display the "." at equal distance. Herewith i've attached the sample code again Please check this. and tell me what should i changed. And also i dont want to show "_" in inputmask. I need empty space.



Thank you .

moosa
31st March 2010, 14:17
Did you consider changing the QLineEdit font to a font with a fixed width? say "Courier New"?
something like this:


ui->lineEdit->setFont(QFont("Courier New"));