How to Print String Literal and Qstring With Qdebug in C++? Last Updated : 28 Apr, 2025 Comments Improve Suggest changes 1 Likes 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 Create Quiz Comment M maverick_vf142 Follow 1 Improve M maverick_vf142 Follow 1 Improve Article Tags : Technical Scripter C++ Technical Scripter 2022 CPP Strings Programs Explore C++ BasicsIntroduction to C++3 min readData Types in C++6 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++3 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++12 min readFile Handling in C++8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++6 min readPolymorphism in C++5 min readEncapsulation in C++3 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL2 min readIterators in C++ STL10 min readC++ STL Algorithm Library3 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples4 min read Like