Unsolved Edit a QString
-
Hi, I have a QString str, as function parameter I need to edit it inside the function, say
void edit(QString str)
{
//Edit str here
// like str[i] = str[i] + 10;
// Changes should be saved in str and to be reflected in called function
}I know how to do this with char*
char str[] = "Hello";for (int i = 0; i < strlen(str); i++)
str[i] = str[i] + 10;How to do the same with QString
-
Learn the C++ language before attempting to use Qt. Most of the framework won't make sense to you unless you understand the basics.
-
Hi
This is not really a Qt issue but more the difference between
using char * and string class type.
Anyway, You are giving it a copy. so anything you do in
the function will not reflect in the original.void edit(QString str) << sends a copy { } void edit(QString &str) << sends a refernce so we modify the orginal { }
-
:) Ok got it
-
@QtFranchise so is your issue solved? please don't forget to mark your post as such!