I've a char array and i want to convert to QString.
Is there a way to do this ?
char text[24]
to Qstring ???
I've a char array and i want to convert to QString.
Is there a way to do this ?
char text[24]
to Qstring ???
What about ?
Infact i try
QString MYstring(text);
But compliler :
no match for call to '(QString) (char [24])'
...Any help ??
works fine for me. How does your code look like?Qt Code:
char text[] = { 'H', 'e', 'l', 'l', 'o', '\0' }; qWarning() << text << string;To copy to clipboard, switch view to plain text mode
Ok this is my code
struct person {
char name[24];
char surname[24];
};
person P;
strcpy (P.name,"TESTNAME");
QString MYstring(P.name);
The compiler gives the error above...
Hm, builds fine with my. Which compiler do you use?i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
gcc version 4.1.2 under Linux...without any problems....
If QT_NO_CAST_FROM_ASCII is defined then the conversion constructor from const char* is made private and the compiler would generate an error (similar but not identical to this though). If that is the case, use QString::fromAscii(), QString::fromLatin1(), or QString::fromLocal8Bit() as appropriate.
I've not defined any QT_NO_CAST_FROM_ASCII....
i used QT 4.2.3...on linux...
Edit: deleted, because my answer was rubbish. Haven't thought it through...
Last edited by Lykurg; 13th December 2011 at 08:59.
Hi,
I use linux Ubuntu 10.04 with :
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
Using Qt version 4.6.0
and that above method THank you
Hi,
I use linux Ubuntu 10.04 with :
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
Using Qt version 4.6.0
and that above method working in my computer
Thank you.
In older gcc and QT
I have to use
MyString.append(vect_char)
Bookmarks