View Full Version : Problem with QT 4.6 qDebug and QString.
weaver4
10th January 2010, 21:40
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.
weaver4
11th January 2010, 01:47
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.
ComaWhite
11th January 2010, 04:49
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);
weaver4
11th January 2010, 17:07
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>
tsp
11th January 2010, 18:26
#include <QDebug>
According to qDebug (http://doc.trolltech.com/4.6-snapshot/qtglobal.html#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:
qDebug() << "string";
Please note the "()" charcters. If that still does not work, please provide a minimal example code with the problem.
weaver4
11th January 2010, 18:59
Nope neither QDebug or QtDebug would cause this statement to work.
qDebug() << str;
Same error.
wysota
12th January 2010, 00:06
Try this:
#include <QtDebug>
int main() {
qDebug() << "Testing";
qDebug() << QString("QString works as well");
return 0;
}
rwtmoore@hotmail.com
18th March 2013, 12:15
If you're using Qt Creator, goto Projects/ Run Settings/ Run and click checkbox titled "Run in terminal"
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.