Book Image

Application Development with Qt Creator - Second Edition

Book Image

Application Development with Qt Creator - Second Edition

Overview of this book

Table of Contents (20 chapters)
Application Development with Qt Creator Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Representing data using Qt's core classes


Probably the most common Qt core class you'll run into is QString, Qt's container class for character strings. It has similar capabilities to the C++ STL class, std::wstring. Like wstring, it's multibyte. You can construct one from a traditional C-style char * string or another QString.

QString has lots of helper methods, some of which are as follows:

  • append: This appends one QString class onto another

  • arg: This is used to build up formatted strings (instead of sprintf)

  • at and operator[]: These you can use to access a single character in the QString

  • operator==, operator!=, operator<, operator>, operator<=, and operator>=: These compare two QStrings

  • clear: This empties a QString and sets it to the null string

  • contains: This searches one string for another string or a regular expression

  • count: This counts the occurrences of a substring or character in a QString

  • startsWith and endsWith: These return true if a QString starts with or ends...