How to Print String Literal and Qstring With Qdebug in C++? Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Printing string literals and QString with QDebug in C++ can be a useful tool for debugging. By printing out the contents of a string or QString, you can quickly identify any issues that may be present in your code. In this article, we’ll discuss how to print string literals and QString with QDebug in C++. The first step is to include the header file <QDebug>. This header file provides access to the debug output stream, which is used for printing out data. Once you have included this header file, you can use the qDebug() function to print out data from a string literal or a QString object. When printing out data from a string literal, you simply need to pass it as an argument into qDebug(). For example: qDebug("This is my string literal"); This will print “This is my string literal” to the debug output stream. You can use the qDebug() function to print both string literal and QString with QDebug. For example: Printing a string literal const char* str = "Hello World!"; qDebug() << str; Printing a QString QString qstr = "Hello World!"; qDebug() << qstr; C++ #include <QDebug> #include <QString> int main() { // Print String Literal qDebug() << "This is a string literal"; // Print QString QString str = "This is a QString"; qDebug() << str; return 0; } Output: This is a string literal This is a QString Comment More infoAdvertise with us Next Article How to write long strings in Multi-lines C/C++? M maverick_vf142 Follow Improve Article Tags : Technical Scripter C++ Technical Scripter 2022 CPP Strings Programs Practice Tags : CPP Similar Reads How to write long strings in Multi-lines C/C++? Image a situation where we want to use or print a long long string in C or C++, how to do this? In C/C++, we can break a string at any point in the middle using two double quotes in the middle. Below is a simple example to demonstrate the same. C #include<stdio.h> int main() { // We can put tw 2 min read string::rbegin() and string::rend() in C++ The std::string::rbegin() and std::string::rend() functions in C++ are used to fetch the reverse iterators to the string. They are the member function of std::string and are used when we want to iterate the string in reverse. In this article, we will learn how to use string::rbegin() and string::ren 2 min read std::string::append vs std::string::push_back() vs Operator += in C++ To append characters, you can use operator +=, append(), and push_back(). All of them helps to append character but with a little difference in implementation and application. Operator += : appends single-argument values. Time complexity : O(n)append() : lets you specify the appended value by using 6 min read std::string::back() in C++ with Examples This function returns a direct reference to the last character of the string. This shall only be used on non-empty strings. This can be used to access the last character of the string as well as to append a character at the end of the string. Length of the string remains unchanged after appending a 2 min read How to print or output a String? In this article, we are going to learn how to print or output a string using different languages. Strings are considered a data type in general and are typically represented as arrays of bytes (or words) that store a sequence of characters. Strings are defined as an array of characters. Topics: Lang 3 min read How To Convert a Qstring to Hexadecimal in C++? In CPP Qt5 has a QString class for working with strings. It is very powerful and has numerous methods, A Unicode character string is made available via the QString class. A string is kept as a 16-bit QChar. Unicode 4.0 characters are represented by one QChar each. A QString can be changed, unlike st 2 min read Like