[SOLVED]Pointer to the first character of a QString?
-
Hi everyone,
Does anyone know how can I get a pointer to the first character of a given string?
I have a small function similar to
@static QString firstChar(const QString s)
{
c = s.at(0);
return c;
}@that will return the first character of a string, yet I decided it would be better if I just got a pointer to the first character of my original string.
Thank you for your time.
-
How about this "one.":http://doc.qt.io/qt-5/qstring.html#constData
-
Quick question: I also noticed below that, the function QString::​constData(), but I couldn't find any examples so I am not sure I understood how can I iterate a QString using it.
EDIT:
I also understood how to use constData. After a few tests I think I am ok now. Thanks for the link.