Solved Can qDebug() print a c struct instance?
-
Just c struct, not c++ class.
-
@Mr-Pang
Hello,
A C struct is not much different from a C++ class beside the default access specifier being public. That said, it is possible to write a custom type to the debug stream if you provide your own operator for that. There's an example in the documentation how this could be achieved.Kind regards.
-
@Mr-Pang said:
Just c struct, not c++ class.
To complete @kshegunov's answer, qDebug() cannot magically print a C++ class. It can display information for all classes which have an overload of
operator<<
. Therefore, the same is also valid for a POD structure (aka C struct). -
Got it. Thank you.