QT 5.0 QDebug compilation error

断了今生、忘了曾经 提交于 2019-12-30 08:16:57

问题


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


回答1:


Try this:

qDebug() << "hello";



回答2:


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.



来源:https://stackoverflow.com/questions/15364070/qt-5-0-qdebug-compilation-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!