Basic string operations

The most basic tasks that involve text strings are the ones where you add or remove characters from the string, concatenate strings, and access the string's content. In this regard, QString offers an interface that is compatible with std::string, but it also goes beyond that, exposing many more useful methods.

Adding data at the beginning or at the end of the string can be done using the prepend() and append() methods. Inserting data in the middle of a string can be done with the insert() method that takes the position of the character where we need to start inserting as its first argument and the actual text as its second argument. All these methods have a couple of overloads that accept different objects that can ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.