copying byte to Qstring
-
hi
i am getting an error while using the strcpystrcpy(arr[i][j], str); here arr is a 2D array and str is Qstring
i tried using qstrcpy also still the same error
error says i cannot copy a connst char * to QStringi canot change the data type of both of them because it is used in many places in the prooject and i need arr as 2D array only same with the str also i cannot change its datatype
this is very urgent please someone help me out thanks in advance
-
@seok said in copying byte to Qstring:
strcpy(arr[i][j]
Try using this one:
strcpy(arr[i][j], str.toStdString().c_str());
or
qstrcpy(arr[i][j], str.toStdString().c_str()); -
hi
i am getting an error while using the strcpystrcpy(arr[i][j], str); here arr is a 2D array and str is Qstring
i tried using qstrcpy also still the same error
error says i cannot copy a connst char * to QStringi canot change the data type of both of them because it is used in many places in the prooject and i need arr as 2D array only same with the str also i cannot change its datatype
this is very urgent please someone help me out thanks in advance
@seok said in copying byte to Qstring:
error says i cannot copy a connst char * to QString
Of course, strcpy has no idea what QString is (check its signature).
Why do you want to use strcpy in a C++ Qt application?
You can use https://doc.qt.io/qt-5/qstring.html#append-1 instead.str.append(QChar(arr[i][j]));