#include#include #include int main() { QChar spaceChar = ' '; qDebug() << spaceChar.isSpace(); // Output: true QChar nonSpaceChar = 'A'; qDebug() << nonSpaceChar.isSpace(); // Output: false QString str = "Hello World"; qDebug() << str.at(5).isSpace(); // Output: true }
#includeThis example demonstrates how to use the isSpace() method to remove spaces from a given string and prints the result to the console.#include #include int main() { QString str = " Hello World "; QString noSpaces = ""; for (int i = 0; i < str.length(); ++i) { if (!str.at(i).isSpace()) { noSpaces.append(str.at(i)); } } qDebug() << noSpaces; // Output: "HelloWorld" }