c++ - How to redirect qml's console.log() to cpp stdout -
i using qml( qtcreator ) , cpp (visual studio).
usually error messages shown console, both cpp , qml.
my requirement should not have console.
so wrote window application.
but when flag has been set, should launch console. , show corresponding error messages there.
i have used following code in function set this.
handle handle_out = getstdhandle(std_output_handle); int hcrt = _open_osfhandle((long) handle_out, _o_text); file* hf_out = _fdopen(hcrt, "w"); setvbuf(hf_out, null, _ionbf, 128); // redirecting buffers file handle *stdout = *hf_out; *stderr = *hf_out; //attach std input console handle handle_in = getstdhandle(std_input_handle); hcrt = _open_osfhandle((long) handle_in, _o_text); file* hf_in = _fdopen(hcrt, "r"); setvbuf(hf_in, null, _ionbf, 128); *stdin = *hf_in;
this print error log stdout , stderr console.
to redirect qt error logs can use.
how redirect qdebug, qwarning, qcritical etc output?
but how redirect output console.log() of qml console.
thanks in advance.
here can find more verbose explanation.
console.log
qdebug
, there no difference end use. code should work, guess have not tested properly. although, code seems strange because unnecessarily platform specific.
likely should rid of that.
by way, qt 4 implementing similar qml viewer. here can find code implementation example, in doubt.
hope, reply answers question. if not, please clarify.
Comments
Post a Comment