Problem with QT 4.6 qDebug and QString.
If I do the following code I get a compile failure;
error: no matching function for call to 'qDebug(QString&)'
QString s = "Test";
qDebug(s);
I have tried using qDebug("%s",s) and qDebug(s.toAscii()), but those don't work either.
I also tried (and I included <QDebug>):
qDebug << s;
I am sure this use to work in previous versions.
I tired a search, but no answer.
Re: Problem with QT 4.6 qDebug and QString.
After working with for another hour I found that I can use QString.toLatin1().
qDebug(s.toLatin1());
Sorry, but that is flat ugly; there has to be a better way.
Re: Problem with QT 4.6 qDebug and QString.
There is. just include #include <QDebug>
then you can just do qDebug() << str; This works perfectly for me.
Also you can do qDebug() << qPrintable(str);
Re: Problem with QT 4.6 qDebug and QString.
It does not work for me. I get this error.
/home/me/Development/Qt-Projects/PodCastBurner/mainwindow.cpp:63: error: no match for ‘operator<<’ in ‘qDebug << msg’
Are you using 4.6?
And yes I did add this line:
#include <QDebug>
Re: Problem with QT 4.6 qDebug and QString.
Quote:
Originally Posted by
weaver4
#include <QDebug>
According to qDebug documentation the file to include is <QtDebug> not <QDebug> and once you have included that file then you should be able to use next format of qDebug:
Code:
qDebug() << "string";
Please note the "()" charcters. If that still does not work, please provide a minimal example code with the problem.
Re: Problem with QT 4.6 qDebug and QString.
Nope neither QDebug or QtDebug would cause this statement to work.
qDebug() << str;
Same error.
Re: Problem with QT 4.6 qDebug and QString.
Try this:
Code:
#include <QtDebug>
int main() {
qDebug() << "Testing";
qDebug
() <<
QString("QString works as well");
return 0;
}
Re: Problem with QT 4.6 qDebug and QString.
If you're using Qt Creator, goto Projects/ Run Settings/ Run and click checkbox titled "Run in terminal"