No application output in QtCreator debug - qt

With QtCreator 2.8 under Win7 with CDB debugger, I cannot see in the
Application Output tab all my fprintf(stdout) stuff !?
I tried:
fprintf(stderr, "...");
fprintf(stdout, "..."); fflush(stdout);
Nothing happens.
In the meantime, If I check the "Run in terminal" option, it works !?
Although I noticed that all the output go to debugger log !?
Any idea ?

As a workaround you can enable the output in CDB console: tools/options/debugger/cdb then check "Use CDB console".
To show the debugger, right click on some window header and select "Debugger Log".
You may also right click on the debugger log view to disable the verbose log.
Btw, I also noticed that the standard application output window works well when you "attach to the running process" instead of starting it from qtcreator.

Not an answer, just a comment that this is obviously a "feature" and isn't going
to get fixed.
I've just started porting a C++/Qt project that has been developed under linux with GCC and Clang, and Windows 7 with MinGW GCC, to Windows 10 with MSVC. If my test code is run as individual programs it reports "All tests passed" (or not), to the console, (std::cout) which in this case is the Qt Creator Application Output window. It has been working on all systems, with all compilers, in both debug and release mode, for years. It now doesn't write to the Application output window when run via the debugger, only if run as if it was the release version.
On discovering this (2021-04-16), I Googled for the solution, and landed here.

I know that this answer do not answer the original question, but since when searching for "No application output" we found this answer...
See the following answer: https://stackoverflow.com/a/26325743/808101.
This only apply to qDebug() and similar functions (not direct output to stdout/stderr).
In my case, I have to set QT_ASSUME_STDERR_HAS_CONSOLE environment variable to 1 in QtCreator in order to see qDebug() messages inside "Application Output" window. For older version of Qt see linked answer for old/deprecated environment variable.

I often use qDebug this way.
#include <QDebug> in the top of the file
Usage:
qDebug() << "This is a Test";
It runs well when using QT creator and does not matter in GUI programming or Console Application.

Related

Qt Creator no longer displays console output in Application Output window after Windows 10 1809 update

I'm running an application in debug with Qt 5.2.1 and Qt Creator 4.5.0. For many months this has been fine, and the console output is shown in the Application Output window. I applied the 1809 update to Windows this morning, and now I only see exception details in the output window, nothing else.
Interestingly, when I "Run in Terminal" the output is shown in the command window. It's also shown if I "Run" (ctrl-R) the application. It also seems to be OK when I run the tests for an application with a later version of the Qt framework (5.12.1, in my case).
Has anyone else experienced this? I'm not even sure where to start with fixing the problem.
EDIT: More information. I looked at the Qt 5.2.1 sources and saw that the qDefaultMessageHandler doesn't output the message if a console window is attached to the process (as you'd expect, for example if you selected the "Run in Terminal option"). If I call FreeConsole() at the beginning of my application, then the output appears as it used to in the Application Output window. This suggests that the update to Windows has caused a console window to be allocated to the debug process.
Change the settings, Edit>Preference>Built&Run>General Tab> Default for run in terminal.
choose those options as u wish.
u can individually change the settings for projects, Select Projects tab > Built & Run >Run >Run in terminal
It might be a bug in Qt 5.2, especially if it works with later Qt versions.
The right answer is: upgrade to a later version of Qt.
The reason is that Qt 5.2 support ended more than 3 years ago.
You should be using one of the currently supported version: 5.9.8, 5.12.4 or 5.13.0.
Note that 5.9 and 5.12 are LTS, but 5.9 support is due to end next year. So 5.12 seems to be the best fit if you don't want to upgrade every 6 months.
Edit
If you cannot update the production version of Qt for any reason, you can at least update Qt Creator on your system and update your development version of Qt.
Let's say you use Qt 5.9 or 5.12 on your computer when you write and test code. But keep 5.2.1 for any other part of the dev loop (testing, CI, ...) and for production.
Qt offers great compatibility across versions, if you write code that compile for 5.2, it will compile without change for any 5.x with x >= 2.
For those of you that are interested, I worked around the problem by conditionally calling FreeConsole() at the beginning of the program, like this:
#ifdef Q_OS_WIN
#include <Windows.h>
#endif
...
#ifdef Q_OS_WIN
#if QT_VERSION <= QT_VERSION_CHECK(5, 2, 1)
// Since the Windows 10 1809 update was pushed, the debug process has a
// hidden console window allocated to it. This prevents the application output
// reaching the console window in Qt 5.2.1 (see qlogging.cpp in the qt source for
// reasons why). This detaches that console window, meaning the output is shown in the
// application output window again. However, if "Run in terminal" is selected in the
// Run options then the output will still be shown in the Application Output window.
FreeConsole();
#endif
#endif
The solution is pretty simple:
Add
CONFIG += console
To your .pro file

How do I know which console command Qt is building the project on?

My project unlike this issue is going through MSVC and I'm having troubles with nmake. Is there a way to just see what commands Qt Creator uses when I press Ctrl+R?
Simply click down on the "Compile Output" pane, and it will show you the exact commands that are issued to build the project.

No log output Qt Creator

A few days ago my Qt Creator stopped to display log output. I didn't change any settings and it seems to be a proplem with the whole project, as my teammates had the same issue after checking out the latest version from GIT. Changing back to a former version does not solve the issue! Any suggestions?
I has same issue. My answer is very simple...
Make sure your selected build kit is Debug not Release :)
Check whether stderr/stdout have been redirected anywhere in the program. I have code that does that intentionally using freopen for my error handler to redirect stderr to a text file since I have no console.
While in debug mode, I make sure to print both to the Qt Creator console and to the text file.

can’t debug in qt sdk 1.2-during startup program exited with code 0x0

Today I found that I could not debug in pure C projetc, but I could debug in qt gui project.
The error was “ during startup program exited with code 0×0”.
I was using Win 7 ultimate 64bit sp1. I had tried in another computer, it was the same.
My program ran when I was not trying to debug it.
Could someone help?
Qt SDK 1.2 includes qt lib 4.8 and qt creator 2.4.1.
Uncheck run in terminal, in Projects -> Run Options
If the debugger does not work properly, try the following:
Make sure you use at least Qt Creator 2.1.
Make sure the debugger is set up properly. For more information, see Setting Up Debugger.
In the Debug mode, select Windows > Views > Debugger Log to open the Debugger Log view. Browse the contents of the pane on the right hand side to find out what went wrong. Always attach the contents of the pane to debugger-related questions to the Qt Creator mailing list (qt-creator#trolltech.com) or paste them to creator.pastebin.com before asking questions in the IRC (on the #qt-creator channel at FreeNode).

Qt Creator cannot preview QString when debugging

List item
Qt-Creator 2.2.0
OSX Lion
"Use debugger helpers" is checked
"Built" and "re-built" all the helpers.
Still... break point on method with QString and the content of the QString cannot be previewed on the debugging pane unless I go to the memory window and search for it manually with the address. I have to use qDebug to dump strings out as if we're in 1983. This use to work and I have no idea what happened to it. Every other type works well.
On Windows 7, the debugger can preview QString objects.
Pastebin the debugger log (right pane of Windows->views->Debugger Log) somewhere and post the link here. And perhaps the log file of the debugger helper rebuilding that you tried?
I had the same problem but after some research I found the answer here:
http://silvermace.com/2010/09/qt-creator-debugger-not-displaying-qstring/
I had to chose the correct qmake path and then I had to build the GDB Helper.
As the original site is gone, here are the steps:
sudo rm /usr/local/Qt4.6/qtc-debugging-helper/libgdbmacros.dylib
Start Qt Creator
Qt Creator -> Preferences -> Select the “Qt” tab -> Select “Qt in PATH” under “Auto-detect”
There should be a red cross next to the label “Debugging Helper.” On the right of that there’s a rebuild button – hit it and wait.
The red cross should turn into a green tick.
Clean & Build your project.

Resources