user1553386
user1553386

Reputation: 143

QT 5.0 QDebug compilation error

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()'

Upvotes: 11

Views: 12925

Answers (3)

Abdullah Leghari
Abdullah Leghari

Reputation: 2470

For version 5.15 of Qt following worked for me,

add include file,

#include <QDebug>

and use,

qDebug() << "Your debug message.";

Upvotes: 1

user123
user123

Reputation: 9071

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.

Upvotes: 4

Leo Chapiro
Leo Chapiro

Reputation: 13994

Try this:

qDebug() << "hello";

Upvotes: 17

Related Questions