View Full Version : How to get ASCII value of each character of a QString?
askrina
11th April 2010, 02:17
Hi, I m new to QT and learning it (version 4). I am trying to get ASCII of each character present in QString.
int asciiVal;
QString name =ui->lineEdit->text();
for(int i=0; i <= name.length(); i++)
{
// Get ASCII VALUE into asciiVal
}
// SHow into another lineEdit
ui->lineEdit2->setText(asciiVal);
Lesiok
11th April 2010, 10:06
asciiVal = name.at(i).toAscii();
askrina
11th April 2010, 12:00
Yes it working, Thank.
I also found other way to do it.
strcpy(asciiVal,name.toLatin1());.
askrina
11th April 2010, 12:06
How to get Char value of each ASCII to QString?
lyuts
11th April 2010, 12:52
Just pass that value to QChar construtor.
askrina
11th April 2010, 13:00
Could you please show the code!
JackHammer
11th April 2010, 13:59
You can use this.
QChar ch = string.at(i).toAscii();
int chValue = ch.toAscii();
lyuts
11th April 2010, 19:39
e.g.
Char to ASCII
QChar c;
// ...
int ascii = c.toAscii();
ASCII to char
int ascii;
// ..
QChar c(ascii);
//or
QChar d;
d.fromAscii(ascii);
askrina
14th April 2010, 05:54
thanks all you
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.