Changed old C code of QT example to new C++ code