Jyoti.verma
24th August 2009, 22:40
Hi
I am new in QT.
I am trying to convert text string to hexadecimal.
void string2hex::browse()
{
QString str="abcd";
QString res;
res = String2Hex(str);
QMessageBox::information(this,tr("Output is"),res);
}
QString string2hex:: Byte2Hex(unsigned char c)
{
//code which convert bytes into hex
}
QString string2hex:: String2Hex(QString S)
{
unsigned int StrLen = S.length();
QString Result;
for (unsigned int i = 0; i < StrLen; i++)
Result += Byte2Hex((unsigned char)S[i]);
return Result;
}
I gives the compilation error
string2hex.cpp: In member function ‘QString string2hex::String2Hex(QString)’:
string2hex.cpp:53: error: invalid cast from type ‘QCharRef’ to type ‘unsigned char’
So can anyone tell me how to do this type casting?
thanks in advance.
I am new in QT.
I am trying to convert text string to hexadecimal.
void string2hex::browse()
{
QString str="abcd";
QString res;
res = String2Hex(str);
QMessageBox::information(this,tr("Output is"),res);
}
QString string2hex:: Byte2Hex(unsigned char c)
{
//code which convert bytes into hex
}
QString string2hex:: String2Hex(QString S)
{
unsigned int StrLen = S.length();
QString Result;
for (unsigned int i = 0; i < StrLen; i++)
Result += Byte2Hex((unsigned char)S[i]);
return Result;
}
I gives the compilation error
string2hex.cpp: In member function ‘QString string2hex::String2Hex(QString)’:
string2hex.cpp:53: error: invalid cast from type ‘QCharRef’ to type ‘unsigned char’
So can anyone tell me how to do this type casting?
thanks in advance.