K
K
Kalombyr2021-04-29 14:12:23
Qt
Kalombyr, 2021-04-29 14:12:23

How is newline implemented in qDebug()?

Greetings!
In Qt, there is
qDebug()<<a<<b<<c;
with the help of which the stream is output to the console / where it is indicated.

And so, interests, thanks to what there is a transfer to the following line?
That is, how is the definition implemented that nothing more will be added to the stream (the last<<) and you can display all the content?
I tried to understand in the source codes, but I did not understand what kind of trick it was.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xorknown, 2021-04-29
@Kalombyr

I don't think a big answer is needed. I will describe approximately.
The qDebug macro returns a temporary QDebug object into which any data is written. After ";'" it is destroyed as a temporary object. And in the destructor, it simply calls the "qt_message_output" function, which writes somewhere, not the point, and passes all the accumulated parameters to it. And it is this function that adds newline to the output.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question