PDA

View Full Version : Conversion of int to char insertion into a qString



yahalimu
19th December 2015, 17:51
Hello,

I have this..

(hpos is an integer)

senddata = ("#MS"+ (QByteArray::number(hpos)) +"$");

This works well and sends..'#MS65$' for example. (if hpos=65)

My problem is I do not want to send a string with the encoded deimal value, I need to convert hpos into the ascii char of value hpos..(ie. 'A' in this case) and insert in the string.

Everything between the #MS and the $ will consist of many successive 8 bit values (data) for a uP.

I know this is simple and will kick myself.. Tin hat on..

Iain

Qiieha
19th December 2015, 20:16
Take a look at QChar. I think theres one constructor, which takes an unsigned int as parameter(code).

QChar(uint code)

yahalimu
19th December 2015, 22:13
OK, thanks for your input.

Still plugging away but no luck yet, sure its a simple solution.

yahalimu
20th December 2015, 12:32
OK, Im sure theres a more elegant way but its solved by creating a ByteArray of one element and inserting that into the QString.
Implicit conversion