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

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

Related

Design Mode requires a valid Qt kit, but installed and are able to run?

In Qt Creator it is possible to run the program clicking the green play button (using PySide6), but not edit the qml file in Design mode, where it gives the error "Line 0: The Design Mode requires a valid Qt kit" inside the design view. I created a project and selected Qt for Python (qml).
But I have installed several gb of the newest Qt version during installation? I have also selected the correct python env in the options.
When I create a non-qml project, but add a .qml file later a popup error says:
"The QML emulation layer (QML Puppet) cannot be built because the Qt version is too old or it cannot run natively on your computer. The fallback emulation layer, which does not support all features, will be used"
The Qt version is 6.2.2 and the OS is Windows 11. It is possible to use design mode in Qt Design Studio.
I meet the same problem and my environment is similar, choose Edit → Preferences and enter the Kits. Then select a Qt version and a kit you like (the type of qmake shall be the same, for instance, both of them is msvc), and remember to apply the changes.
After that, go back to the form editor and it works well. What confused me is that I must repeat the steps above each time I want to use Qt, the config seems to not be saved correctly. (The Qt version is 5.1.2 and the OS is Windows 11)
PS: After selecting the kit, you need to restart Qt.

Using MSVC with QT creator: The clangbackend process has finished unexpectedly and was restarted

I'm using Qt Creator 4.7.2 and when I try to make a project using Desktop QT 5.11.2 with MSVC2015 32 bit compiler I get a repeating message under general messages:
Clang Code Model: Error: The clangbackend process has finished unexpectedly and was restarted.
This message is repeating 3 times every second and the text editor is very laggy as well. This only happens when I use the MSVC compiler, it works okay with MinGW. My code is just the basic window code that auto generates when you create a new project. Anyone know how to fix this?
Open Help > About Plugins.... Then, under C++, disable ClangCodeModel.

No application output in QtCreator debug

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.

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 build for Wince works, but no plugins or import work

I've got Qt build for a CE 6 custom sdk. I can use VS2005 and a KITL connection and run several of the Qt examples successfully on the device. I can also run examples if I copy all of the Qt dll's into a directory with the .exe on a USB drive and attach it to the device.
However, it seems that anything that uses QTDIR to find the location doesn't work (plugins and QML imports). I was able to get some QML examples to work if I included the qml in the project as a resource file.
Nothing I've tried works (including copying the plugins/imports to a directory with the dlls). I can't set QTDIR, as wince doesn't have environment settings.
I was able to get a little further with a static build vs. shared, but I believe that "nice stuff" like QtWebkit and QtMobility won't be available for static builds.
Is there some secret to deployment on wince that I'm missing?
Tracked it down. In src/corelib/io/qfilesystemiterator_win.cpp there is a code chunk:
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) {
dwAdditionalFlags = 2; // FIND_FIRST_EX_LARGE_FETCH
infoLevel = 1 ; // FindExInfoBasic;
}
The enums for windowsVersion for wince (6.0) are different, causing this to trigger as true instead of false. Wrapping the above code in
#ifndef Q_OS_WINCE
...
#endif
fixes the problem.
Note, I found a git repo for Windows Embedded Compact 7 patches that (as of 4.8.0) is not included in Qt. This fix is one of the changes. Check out https://qt.gitorious.org/qt/jaanttils-qt/graph/WEC7_Patches if you are working on 4.8 and wince (even CE 6). I needed a handful of changes on top, but I think they were specific to the sdk I'm using.

Resources