qdebug

Cannot retrieve debugging output in Qt Creator

こ雲淡風輕ζ 提交于 2019-12-04 00:22:57
In Qt Creator on Windows, qDebug() statements don't work, and the following message appears in the output window: Cannot retrieve debugging output. How can it be fixed? This problem can show up if more than one instance of Qt Creator is active. To fix the issue, simply close all the other instances of Qt Creator and it should work. For me, I solved the problem by simply closing the running application built with the other qt creator. So not necessary to close the other qt creator. Or you may be running a version of DebugView from Sysinternals, that causes the same result. For me this error

qDebug and cout don't work

故事扮演 提交于 2019-12-02 00:35:22
问题 I have this simple code #include <QtCore/qdebug.h> #include <QtCore/qcoreapplication.h> #include <iostream> using namespace std; int main(int argc, char **argv) { cout << "pluto" << endl; QCoreApplication app(argc, argv); qDebug() << "pippo" << endl; return app.exec(); //return 0; } I compiled it with MinGw in Eclipse with no errors, but when I run the code no string message appear on the consolle. What is wrong? Thanks. Luca 回答1: For cout to work on Windows, you need to have CONFIG+=console

qDebug and cout don't work

做~自己de王妃 提交于 2019-12-01 22:25:53
I have this simple code #include <QtCore/qdebug.h> #include <QtCore/qcoreapplication.h> #include <iostream> using namespace std; int main(int argc, char **argv) { cout << "pluto" << endl; QCoreApplication app(argc, argv); qDebug() << "pippo" << endl; return app.exec(); //return 0; } I compiled it with MinGw in Eclipse with no errors, but when I run the code no string message appear on the consolle. What is wrong? Thanks. Luca For cout to work on Windows, you need to have CONFIG+=console in the .pro file. It shouldn't have any effect on any other platform, so you can just add it there. You can

Is qDebug() thread-safe?

余生长醉 提交于 2019-11-30 13:44:01
问题 Is qDebug() thread-safe? By thread-safe I don't just mean not-crashing, but also if I call qDebug() from different threads, is it possible for the output to become mixed-up? I tested it with this code, and it doesn't appear to be so, however, I couldn't find anywhere in the documentation where they talk about this. This is my test code: #include <QtConcurrent> #include <QApplication> void print_a() { for (int ii = 0; ii < 10000; ii++) { qDebug(

Why is QString printed with quotation marks?

99封情书 提交于 2019-11-30 11:50:12
So when you use qDebug() to print a QString , quotation marks appears suddenly in the output. int main() { QString str = "hello world"; //Classic qDebug() << str; //Output: "hello world" //Expected Ouput: hello world } I know we can solve this with qPrintable(const QString) , but I was just wondering why does QString work like that?, and Is there a method inside QString to change the way it's printed? Why? It's because of the implementation of qDebug() . From the source code : inline QDebug &operator<<(QChar t) { stream->ts << '\'' << t << '\''; return maybeSpace(); } inline QDebug &operator<<

Is qDebug() thread-safe?

心不动则不痛 提交于 2019-11-30 08:02:47
Is qDebug() thread-safe? By thread-safe I don't just mean not-crashing, but also if I call qDebug() from different threads, is it possible for the output to become mixed-up? I tested it with this code, and it doesn't appear to be so, however, I couldn't find anywhere in the documentation where they talk about this. This is my test code: #include <QtConcurrent> #include <QApplication> void print_a() { for (int ii = 0; ii < 10000; ii++) { qDebug("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); } } void print_b() { for (int ii = 0; ii < 10000; ii++) { qDebug(

Why does qDebug work in Release builds?

谁说我不能喝 提交于 2019-11-30 03:12:28
Coming from MFC, I treated qDebug() much like TRACE() , assuming that it is removed from Release builds by the preprocessor (in MFC it's done using #define TRACE 1 ? (void*) 0 : AfxTrace ). To my surprise, however, qDebug() is executed in Release builds as well. How do I change this? And also, why is this so, what was the reasoning of the developers of Qt behind this decision? qDebug is also preprocessor-controlled, but it has its own special macro, QT_NO_DEBUG_OUTPUT . If you add that to your Release build defines, it will be removed. QDebug is "output stream for debugging information". It

Why is QString printed with quotation marks?

微笑、不失礼 提交于 2019-11-29 17:02:44
问题 So when you use qDebug() to print a QString , quotation marks appears suddenly in the output. int main() { QString str = "hello world"; //Classic qDebug() << str; //Output: "hello world" //Expected Ouput: hello world } I know we can solve this with qPrintable(const QString) , but I was just wondering why does QString work like that?, and Is there a method inside QString to change the way it's printed? 回答1: Why? It's because of the implementation of qDebug(). From the source code: inline

Why does qDebug work in Release builds?

依然范特西╮ 提交于 2019-11-29 00:48:20
问题 Coming from MFC, I treated qDebug() much like TRACE() , assuming that it is removed from Release builds by the preprocessor (in MFC it's done using #define TRACE 1 ? (void*) 0 : AfxTrace ). To my surprise, however, qDebug() is executed in Release builds as well. How do I change this? And also, why is this so, what was the reasoning of the developers of Qt behind this decision? 回答1: qDebug is also preprocessor-controlled, but it has its own special macro, QT_NO_DEBUG_OUTPUT . If you add that

How to call qDebug without the appended spaces and newline?

非 Y 不嫁゛ 提交于 2019-11-28 17:43:50
I'm using the the C++/Qt print function qDebug, but sometimes I would like to control how ", space and newline is appended and not use the default qDebug. Let's take a simple example: QString var1("some string"); int var2 = 1; qDebug() << var1 << "=" << var2; This will print "some string" = 1 But Let's say that I don't like the appended " and space and would like the print to look like some string=1 How to I then call qDebug? Note: There is a function in qDebug called nospace , but it will remove the spaces. But the " is still there. If I use this: qDebug().nospace() << var1 << "=" << var2; I