View Full Version : get ASCII equivalent data

25th June 2009, 13:38
Dear All,
In my application i need to get the data in ascii format if user types string prefixed by '\' in QLineEdit.

Ex: if user press '\002' then ASCII equivalent is STX(start of text). which is also equivalent 0x02.

if user enters normal text, then it should return same.
Can anyone tell me how can resolve this.???

How can i achieve this

26th June 2009, 05:13
I presume that you want to process the data after the QLineEdit object has lost focus.

If this is the case then I would get the stream of chars input and parse it.

If line is your QLineEdit Object,
QString lineData = line.text();
Recursively look for \ in lineData and if found then parse from there till you find a non numeric character. That process will give you the substring you are looking for.

To parse you can use lineData.indexOf(QChar('\\')). If found , it will give you the position or -1 if not found.

Good luck.