[SOLVED]Pointer to the first character of a QString?
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);
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
Thanks for the pointer.
Is this what you meant?
@const QChar* firstChar(const QString* s)
const QChar* c = s.constBegin();
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.
I also understood how to use constData. After a few tests I think I am ok now. Thanks for the link.