Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QT 5.0 QDebug compilation error

Tags:

qt5

I am having trouble compiling my code with QDebug, but i really need it.

#include <QCoreApplication>
#include <QtDebug>
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QDebug() << "hello";
    return a.exec();
}

This is an example of the error i got on this simple test: no matching function for call to 'QDebug::QDebug()'

like image 709
user1553386 Avatar asked Mar 12 '13 14:03

user1553386


3 Answers

For version 5.15 of Qt following worked for me,

add include file,

#include <QDebug>

and use,

qDebug() << "Your debug message.";
like image 118
Abdullah Leghari Avatar answered Dec 04 '22 06:12

Abdullah Leghari


Try this:

qDebug() << "hello";
like image 32
Leo Chapiro Avatar answered Dec 04 '22 05:12

Leo Chapiro


The problem here is that QDebug does not have a default constructor. QDebug() << "hello"; would work if it did have one.

These are the available constructors:

QDebug(QIODevice* device);
QDebug(QString* string);
QDebug(QtMsgType type);
// and the copy constructor of course.

duDE's answer gives you what you're looking for.

like image 44
user123 Avatar answered Dec 04 '22 07:12

user123