GDB Pretty printers for Qt5
Switch branches/tags
Nothing to show
Clone or download
Latest commit 838e4fd Oct 12, 2018
Failed to load latest commit information. Fix formatting typo in the readme Aug 21, 2016 Python 3 compatibility Aug 3, 2015 cast address to int Oct 8, 2018 fix gdb crash Aug 10, 2017


The, and files are taken from patchset 2 at and provide a GDB pretty printer for Qt5. These are authored by Alex Merry from the KDE project.


Copy the three Python files to ~/.gdb/qt5printers/ and add this to your ~/.gdbinit (or execute it from an existing gdb session):

import sys, os.path
sys.path.insert(0, os.path.expanduser('~/.gdb'))
import qt5printers

Now verify it with your favorite program. Below you can find a quick test program.

Test program

Here is a test program (save it as test.cpp):

#include <QTextStream>
void test(const QByteArray & ba) { }
int main(void) {
    return 0;

Compile it with:

g++ test.cpp $(pkg-config --cflags --libs Qt5Core) -g

If everything goes well you should see the expanded data:

$ gdb -q -ex break\ test -ex r ./a.out
Breakpoint 1, test (ba="abc" = {...}) at test.cpp:4
4           test(QByteArray("abc"));


The Qt4 pretty printers from KDevelop0 are not fully compatible with Qt5. For instance, the latest version (from December 2014) does not properly handle QByteArray. While these qt5printers are compatible with Qt5, it conflicts with Qt4 (for example, QByteArray changed in Qt 5 from Qt 4 in this commit1).

See also:


For the applicable licenses, see the headers of the files and refer to the Qt5 sources at