0

Please note this is not C++ code and I'm not developing a Qt app.

I mostly develop embedded code and someone has knocked up a neat LCD emulator so we can write quite a lot of the code independent of the target platform (which will be embedded ARM). He's given me a gcc make file and C files which I have imported into Qt creator on a Linux desktop. It can be compiled for different platforms just with some gcc options. So although it will eventually work on an STM32 for the moment I can write code on a computer. He does it on Windows, but I'm doing it on Linux.

I'd like to do some printf commands to spit some debug data out which is something I'd never normally do on embedded developments as the IDE I use has such great facilities for setting breakpoints and looking at registers.

I should say that I can compile a line like this:

printf("Selected Index is %d, Highlighted Position is %d, Index Start is %d \n",selected_index,highlight_position,index_start);

But I'm seeing no output in the Debugger Console.

If I'm using Qt creator to write GUIs on the rare occasions I want to do print out data on the fly I'll just write to a debug window.

If I want to do a printf for a bog standard C program using Qt creator, how can I get printf to spit out data to the debugger console? In fact can it be done?

I can't use the usual Qdebug facility as I am not using any sort of Qt framework. I'm simply using Qt as an IDE and debugger for ARM C code.

2
  • I never used QT creator for developing non-QT applications, so I do not know how it manages the debug console, but 1) apart from the debugger console there is also the window "Program output" (or something like this, I do not remember the actual name); if you do a printf it should appear there (or at least that's where the output of QT console applications go). 2) What if you print to STDERR instead of STDOUT? 3) if nothing else works, you can write to a file and read it to check the output. Not the most user-friendly way to handle data, but it can be a quick solution Commented Mar 8, 2019 at 13:00
  • fprintf(stderr,"Selected Index is %d, Highlighted Position is %d, Index Start is %d \n",selected_index,highlight_position,index_start); This prints to Application Output. Add that as an answer and I'll vote you up. Many thanks. :) Commented Mar 8, 2019 at 13:15

1 Answer 1

1

As written in a comment (which I wrote as a comment because I do not have QT here and so cannot check it, nor have I used in the past months, so I was not sure), there are some solutions you can try:

  • There is another window in the bar alongside with the Debugger Console, called "Application Output", where the output of QT console applications go. Maybe the printf is written there
  • Usually both streams (STDOUT and STDERR) are redirected to the appropriate window, but sometimes not. Try changing it
  • The last solution, if nothing else works, is to use a file; write to a debug file and read back what the application has to say. Not as immediate as a direct output, but better than nothing

According to your reply, printing to STDERR shows output on the application output window, so it works also for plain C. I thought that also the STDOUT stream should have been redirected to that window, though

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.