Hi I want to convert a char in QString for example I have this:
QString s;
char a = "cadena"
I want to convert a
in QString
but I do not know how to do it.
Hi I want to convert a char in QString for example I have this:
QString s;
char a = "cadena"
I want to convert a
in QString
but I do not know how to do it.
The code you have entered is incorrect. "cadena"
can not be stored in a char
, but it is necessary to use char*
. In addition, in C ++ the arrangements thus defined are constant by definition, then the correct way to declare it would be:
const char* a = "cadena";
Once this has been solved, to insert a C style string in a QString
you can use several options:
// Operador de asignación
s = a;
// Constructor
QString s = a;
// Método append para añadir texto al final de la cadena
s.append(a);
There are some other methods that allow you to work with char*
, you should take a look at its documentation: link of version 4.8