Skip to Content
Hands-On GUI Programming with C++ and Qt5
book

Hands-On GUI Programming with C++ and Qt5

by Lee Zhi Eng
April 2018
Intermediate to advanced
404 pages
8h 27m
English
Packt Publishing
Content preview from Hands-On GUI Programming with C++ and Qt5

Print variables using QDebug

You can also print out the value of a variable to the application output window, using the QDebug class. QDebug is quite similar to std::cout in the standard library, but the advantage of using QDebug is that since it is part of Qt, it supports Qt classes out of the box, and it is able to output its value without the need for any conversion.

To enable QDebug, we must first include its header:

#include <QDebug> 

After that, we can call qDebug() to print out variables to the application output window:

int amount = 100; 
qDebug() << "You have obtained" << amount << "apples!"; 

The result will look like this:

By using ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C++ GUI Programming with Qt 4

C++ GUI Programming with Qt 4

Jasmin Blanchette, Mark Summerfield

Publisher Resources

ISBN: 9781788397827Supplemental Content