QDebug() does not display anything.
-
Hi All,
I am new on Qt. This question should be basic for most of you but i have no choice to bother you after searching the solution for 1 day. Basically, qDebug() won’t display anything when i create a QCoreApplication is the main() This main.ccp won’t display “test qdebug” :
#include <QtCore/QCoreApplication>
#include <QDebug>
int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);
qDebug() << “test qdebug\n”;
return a.exec();
}Whereas this main.ccp displays “test qdebug” :
#include <QtCore/QCoreApplication>
#include <QDebug>
int main(int argc, char *argv[]) {
qDebug() << “test qdebug\n”;
}Here in my .pro :
QT += core
QT -= gui
TARGET = test13
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cppI also tried to ask CONFIG += debug but it still not work
I also tried to use qDebug() in the constructor of a class, still not working.
I am created this simple project on Qt Creator (Console Application)
I am using GCC 4.4 – GT 4.8.1After reading hours about .pro file, moc, QDebug, I really have no clue why I can’t have qDebug() work.
Thanks in advance for your helpGilles
Paris
-
Hi, please enclose your code in '@' tags, and format nicely, currently it's hard to read it.
-
Below is the code with '@' tags.
I also would like to add that when i download a working example from the net, qDebug() does not work too. So i am pretty sure my issue is related to my desktop/Qt configuration , not to my code.I am new on Qt. This question should be basic for most of you but i have no choice to bother you after searching the solution for 1 day. Basically, qDebug() won’t display anything when i create a QCoreApplication is the main()
This main.ccp won’t display “test qdebug” :
@#include <QtCore/QCoreApplication>
#include <QDebug>
int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);
qDebug() << “test qdebug\n”;
return a.exec();
}@Whereas this main.ccp displays “test qdebug” :
@#include <QtCore/QCoreApplication>
#include <QDebug>
int main(int argc, char *argv[]) {
qDebug() << “test qdebug\n”;
}@Here in my .pro :
@QT += core
QT -= gui
TARGET = test13
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp@I also tried to ask CONFIG += debug but it still not work
I also tried to use qDebug() in the constructor of a class, still not working.
I am created this simple project on Qt Creator (Console Application)
I am using GCC 4.4 – GT 4.8.1After reading hours about .pro file, moc, QDebug, I really have no clue why I can’t have qDebug() work.
Thanks in advance for your helpGilles
Paris
-
Hm. Try if printf works. I remember I had similar problem once, but I can't remember how I solved it, sadly.
PS. No need to add endline - QDebug does that automatically for you.
-
Hm. Your code is works perfectly in my pc:
(Probably you have problem with the quotation mark(s)
Pay attention when you copy-paste some code into your QtCreator, because the copied quotation mark can be wrong)main.cpp
@
#include <QtCore/QCoreApplication>
#include <QDebug>int main(int argc, char *argv[])
{
qDebug() << "test qdebug\n";
}
@.pro file
@
QT += core
QT -= gui
TARGET = test13
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
@ -
Hi there,
Hmm, maybe just easy to ask, but did you check out the little checkbox in the project folder that says run in console mode?
Because that is where the debug will then be put. Otherwise, if you lease the CONFIG += console out it will come in your application output.
Both should work with your code.greetz
-
sierdzio,
I can't even display printf or cout. The following code does not diplay anything :
@#include <QtCore/QCoreApplication>
#include <QDebug>
#include <stdio.h>
#include <iostream>int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);
qDebug() << "test qdebug";
printf("test printf");
std::cout << "test std::cout\n";
return a.exec();
}@and the following code display everything :
@#include <QtCore/QCoreApplication>
#include <QDebug>
#include <stdio.h>
#include <iostream>int main(int argc, char *argv[]) {
// QCoreApplication a(argc, argv);
qDebug() << "test qdebug";
printf("test printf");
std::cout << "test std::cout\n";
// return a.exec();
}@greetz,
In my Qt creator 2.4.1. I can't see any little checkbox for console mode. What i did is to choose debug in the "qmake build configuration" popup menu.My quotation mark(s) looks good. If it not the case, i could not even compile.
-
Seems that the core application is to blame here, but that seems insane. Try running from terminal instead of Qt Creator. Maybe Creator connects to cerr only? Weird.
-
My problem is fixed.
In my c:\windows directory I had all Qt DLL (QtCore4.dll ....) coming from a previous Qt installation i did a few years ago. I don't remember well but i may have put them there manually. And that was the dlls my code was dynamically linked to (maybe because c:\windows appears first in PATH).
After removing those dll from c:\windows, my problem disappeared. The up to date DLL from C:\dev\Qt\Desktop\Qt\4.8.1\mingw\bin are now used.Thanks a lot Guys. I appreciated your help.
-
wow, that is quite unexpected :) Glad you are OK again, though :D
1/10