[Qt-interest] QString from char array

Ankit Agarwal ankit17.ag at gmail.com
Thu Jan 22 04:39:07 CET 2009


Hi,
Here is an example how u can convert QString to char*

QString qstr
  char *str = NULL;
  char *tempStr = NULL;
  if (qstr.isEmpty())
    return NULL;
  QByteArray ba = qstr.toAscii();
  tempStr = ba.data();
  str = strdup(tempStr);

"str" is the final char *.


On Thu, Jan 22, 2009 at 4:14 AM, Donal <donaloconnor at gmail.com> wrote:

> If you have 4 charactors, then you you can read just the four with
> fromAscii(charString, 4);
> If you don't use len, it uses the null character instead, the way you were
> using it and without a null terminator.
>
> Correct me if i'm wrong however
>
>
> On Wed, Jan 21, 2009 at 10:37 PM, RZ <rz at razfazz.at> wrote:
>
>>
>> > Way too obvious... you must of read the docs :)
>> >
>> Well that's one problem. The second - more important - i couldn't see a
>> real relation from my problem to the second parameter. But I might have
>> been wrong though ...
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>


-- 
Regards,
Ankit Agarwal
SW Engineer
Vegayan Systems
email : ankit_agarwal at vegayan.com
Blog : http://ankit17.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090122/65d637d5/attachment.html 


More information about the Qt-interest-old mailing list