Qstring
QString::fromStdString
QStringLiteral
A Qt macro that creates a QString from a hardcoded string literal at compile time rather than runtime, avoiding any memory allocation. It is used wherever you have a fixed string value baked directly into the code rather than a variable. For dynamic values coming from variables, QString::fromStdString() is used instead. QString::fromLocal8Bit
A static factory method on QString that converts raw byte data into a QString using the local system's text encoding. It is used specifically for reading process error output since readAllStandardError() returns raw bytes rather than a proper string. It is preferred over fromStdString() sometimes because error messages from system processes are encoded in the local system encoding rather than UTF-8. QString::trimmed()
A method on QString that returns a copy of the string with all leading and trailing whitespace removed, including spaces, newlines, and tabs. It is commonly used when reading output from external processes since they often append a newline to the end of their output. It does not modify the original string but returns a new cleaned copy. |
Cheatography
https://cheatography.com
C++ (QString) Cheat Sheet (DRAFT) by blakecromar
A cheatsheet on the Qt framework
This is a draft cheat sheet. It is a work in progress and is not finished yet.