Questions tagged [qdebug]

The QDebug class, part of the Qt framework, provides an output stream for debugging information.

Documentation can be found here

99 questions
105
votes
7 answers

How to redirect qDebug, qWarning, qCritical etc output?

I'm using a lot of qDebug() << statements for debug output. Is there any cross-platform way I can redirect that debug output to a file, without resorting to shell scripts? I'm guessing that open() and dup2() will do the job in Linux, but will it…
Septagram
  • 9,425
  • 13
  • 50
  • 81
66
votes
8 answers

How to call qDebug without the appended spaces and newline?

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 <<…
Johan
  • 20,067
  • 28
  • 92
  • 110
34
votes
6 answers

How to print string literal and QString with qDebug?

Is there any easy way to get the following work? I mean is there any helper class in Qt which prepares the string for qDebug? QString s = "value"; qDebug("abc" + s + "def");
B Faley
  • 17,120
  • 43
  • 133
  • 223
27
votes
3 answers

Why does qDebug work in Release builds?

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…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
25
votes
5 answers

Why is QString printed with quotation marks?

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…
Michael
  • 1,018
  • 4
  • 14
  • 30
25
votes
7 answers

Is qDebug() thread-safe?

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…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
23
votes
3 answers

How to enable and disable qDebug() messages

I disable the qDebug() messages by writing CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT in the .pro file. This works fine. I would like to know if there is any way to enable qDebug() messages using the source code. I would like to…
gfernandes
  • 1,156
  • 3
  • 12
  • 29
23
votes
11 answers

Qdebug display hex value

I am trying to display a number using QDebug in the Hex format. Below is the code which I have written. It is working but the output has string contents enclosed in double quotes: How to remove these quotes? m_CanMsg_ptr->id =…
Katoch
  • 2,709
  • 9
  • 51
  • 84
23
votes
5 answers

Cannot retrieve debugging output in Qt Creator

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?
laurent
  • 88,262
  • 77
  • 290
  • 428
19
votes
3 answers

Avoid newline in qDebug()

Sometimes I want to output a single line in qDebug(), but with some conditional text, like if (fontMetricsLeading < 0) qDebug() << "!!!"; qDebug() << fontMetricsLeading; However, that would output them on 2 separate lines. Is there a way to…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
14
votes
9 answers

qDebug not displaying anything

Often when I need to debug something it's easier to print something using qDebug() instead of debugging step-by-step using a debugger. The problem is that from time to time the output of qDebug() isn't displayed at all! The same with qWarning and…
Lukasz Czerwinski
  • 13,499
  • 10
  • 55
  • 65
12
votes
1 answer

qDebug isn't printing a full QByteArray containing binary data

I have a QByteArray to store data received from a GPS, which is part binary and part ASCII. I want to know for debug proposals know what's being received, so I'm writing a qDebug like this: //QByteArray buffer; //... qDebug() << "GNSS msg (" <<…
Roman Rdgz
  • 12,836
  • 41
  • 131
  • 207
8
votes
4 answers

Qt qDebug not working with QConsoleApplication or QApplication

I currently have a terribly annoying problem while developing programs using Qt and Qt Creator. Whenever I try using qDebug() with a QCoreApplication or QApplication instantiated before using qDebug(), there isn't any output, whether I run the…
marius_linux
  • 595
  • 4
  • 14
8
votes
2 answers

qDebug Qt console application to output to Qt Creator application output

How do I use qDebug in a Qt console application to output to the Qt Creator "application output" window? Currently qDebug writes to the console window which interferes with the non-debug output. Using qDebug in a Qt GUI app outputs to application…
Eugene
  • 10,957
  • 20
  • 69
  • 97
7
votes
1 answer

qDebug - How to output data in bits (binary format)

Can qDebug() output the data in binary format? For example, I want to check some status variation: unsigned char status; ... qDebug() << "Status: " << status; I want to generate output in a binary format, something like: Status: 1011
jwm
  • 4,832
  • 10
  • 46
  • 78
1
2 3 4 5 6 7