PDA

View Full Version : How to read value which written inside the QLineEdit



RENOLD
15th February 2012, 13:53
I wanted to know that how can I read the value which is written in side the QLineEdit.
As in spinBoxwe can read it's value by

int a;
a=spinBox->value();
qDebug("%d",a);

Same way I wanted to know the value in to the comboBox.
Is there any way to read this value???

MarekR22
15th February 2012, 14:01
http://developer.qt.nokia.com/doc/qt-4.8/qlineedit.html#text-prop

RENOLD
15th February 2012, 14:12
Hey Marek I wanted to make such that kind of application in which i can write only one character and if i write second character then first character is clear and second character takes it's place.....
So is there any easy solution to do that????

RENOLD
16th February 2012, 06:43
Hello friends I make my application using following code,

QString p;
p=lineEditBox->text();

QStringList stringList= p.split("",QString::SkipEmptyParts);
for (int i = 0; i < stringList.size(); i++)
{
if(i==stringList.size()-1)
{
lineEditBox->clear();
lineEditBox->setText(stringList.at(i));
}
}

I hope this will helpful to someone ... :)

narlapavan
16th February 2012, 14:59
keep line edit box max length to 1 and add slot for that i.e textchanged() for that line edit and inside that slot do what u want.