Qt Creator cannot preview QString when debugging - qt

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.

Related

Running debug mode in Qt Creator

I am trying to compile some demo code (specifically, the pcl_visualizer demo that comes with the Point Cloud library). When running debug by clicking the green arrow with the magnifying class, I get the following errors:
This does not seem to be a "Debug" build.
Setting breakpoints by file name and line number may fail.
Section .debug_info: Not found.
Section .debug_abbrev: Not found.
Section .debug_line: Not found.
Section .debug_str: Not found.
Section .debug_loc: Not found.
Section .debug_range: Not found.
Section .gdb_index: Not found.
Section .note.gnu.build-id: Found.
Section .gnu.hash: Found.
Section .gnu_debuglink: Not found.
Furthermore, none of the breakpoints I have inserted are breaking the program, and they all have little hourglasses hovering over.
In Projects, the Debug mode is selected in Build Settings.
Why does my code not seem to be debugging correctly?
Some projects automatically build debug mode and allow to run it individually. You can then pick it in the bottom left Run selection menu.
Other projects require you to specifically do a debug build.
For example: Kdenlive requires you to run CMake again with the following parameter added:
-DCMAKE_BUILD_TYPE=Debug
You can re-run CMake in the Projects view.
For newer versions of QT:
Go to "Projects" in the top left of the screen, an icon with a wrench that turns green when you select it.
If not already "clicked", click on "Build" under the named Kit (I have "desktop" as my kit). This should be immediately below "Build & Run" on the left side.
Under Build Settings at the top center, should have "Edit build configuration" with a drop down next to it. If you can select "Debug" from the drop down then do it, otherwise click "Add" in the drop down next to it and select "Debug".
Drop down some and see "Key" on the left side of a table of "Key"s with "Value"s, look farther right and see "Advanced" with a square, check the square to get the advanced Key-Value pairs.
Look for "CMAKE_BUILD_TYPE" and click "Edit" in the far right, change the drop down for the value matched to the key CMAKE_BUILD_TYPE to "debug".
Now in the bottom left, change the build configuration to "debug" and build... should work!
You may have to Clean the project and possibly clear cmake configuration under the Build tab.
Another cause for the "does not appear to be a debug build" message is running gdb using the cdb engine. to check go to tools->options->build and run->kits and select the kit you are using. next go to the debugger line, choose edit, and make sure you have the right engine for your debugger.
On linux using the 'Qt Maintenance tool' to install the 'Qt Debug Information Files' solved this for me
I've got the same message because the build type was set to release. On Qt Creator 3.3.0 on the bottom left, on top of the play symbol i have a pc icon with the build type. click on that icon and select debug.
I needed to 'run qmake' too from the menu build.
For nasm users with QT5.9.1 and nasm 2.14 the problem will be gone by using:
nasm -felf64 -FDwarf -g
I know it's not c/c++ related but works very well in QT
To change the Build Configuration in QT Creator :(at time of writing : 4.13.3)
Just make sure you have selected this as Debug so that it would then run in debug mode.
I managed to solve this by unchecking "Warn when debugging Release builds" in the Debug settings General tab, as in the article:
http://www.kdab.com/qt-on-android-episode-2/

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.

QtCreator project Menubar & code portability

As we know programe written in QT is able to port across platform.
At present i am developing programme using QTcreator, here i can directly edit the Menubar & enter item to it.
But the code for this is not atall visible in .cpp files.
like shown here :---
http://codeprogress.com/cpp/libraries/qt/QMenuBarAddMenu.php#.UXYeyaL-EfE
1> Where is the code for this Menubar ?
2> Also another question is that is the GUI program written in (QTcreator in windows) is able to run on Linux host ?
3> Does there QT creator for Linux also ?
Please suggest on this point.
1) In Qt Creator, click on QMenuBar and press "F1" or navigate to "Help > Context Help", while the cursor is on QMenuBar, or you can press "F2" or navigate to "Tools > C++ > Follow Symbol under Cursor", and it will take you to where QMenuBar is defined. The right click menu is very helpful, too.
2) Probably through wine. Though most people would recompile it for other OS's... so download Qt SDK for linux onto a linux distribution, and build it there.
http://qt-project.org/doc/qt-4.8/deployment.html
3) Yes.
http://qt-project.org/downloads
http://qt-project.org/downloads#qt-creator
But be sure to also get the SDK for linux, too.
http://qt-project.org/downloads#qt-lib
Hope that helps.

QtCreator debug pause stop at code not assembly

How can I configure QtCreator so that when I'm debugging and I press pause it would show the code it is currently processing (now it shows assembly). Couldn't find an answer anywhere about this.
I am using Windows 7.
I have this problem with Qt Creator 4.2.2 in Ubuntu 16.04. One of the steps can solve your problem:
Try to swith compile mode in the left corner to Debug mode
Try to switch off option Debug->Operate by instruction, when you debugging. But it doesn't work for me.
Try to switch option Tools->Debugger->Set breakpoint using full absolute path.
Try to add your Qt Src path in window Source Path Mapping (Tools->Debugger->Add Qt sources)
Use only ASCII symbols in your 'project' and 'build' directory paths.
After step 5, there was magic and gdb sucess work in src mode.
It might not have the sources for the code it is currently executing. It could be in a system DLL, for instance. If you look at the stack trace, you might find a function that it has the source for, but this is not guaranteed -- it could be in a thread for which no source is available at all.

Qt - Qml debugging is enabled. Only use this in a safe environment

I'm trying to run a very simple program that just closes the window when clicking the `exit button, but get the following output provided that the application window that contains the button does not show up:
Starting C:\Users\Ola\Desktop\signal_slot1-build-desktop-Qt_4_8_1_for_Desktop_-_MSVC2008__Qt_SDK__Debug\debug\signal_slot1.exe...
Qml debugging is enabled. Only use this in a safe environment!
What should I do in this case?
You have enabled QML debugging (actually it's on by default), this opens a port to the Javascript interpreter that is running the QML so you can get debug output from it. Obviously this creates a security hole, so it should be turned off when not being used in safe place (it's turned off automatically when you release compile). This warning is to remind you of that.
If you are not using QML, turn it off anyway. You can turn it off in the project's options page, where the build settings are (it's a check box in the qmake area).
Assuming you use Qt Creator:
If you select the Release-Build type the QML debugging will be disabled. To do this, select the build type on the bottom left corner above the "run" button and choose "release".
Manually, there is an option passed to qmake (either in the .pro file or via command line arguments) named
CONFIG+=qml_debug
which enables qml debugging.
If you omit that, it should be disabled.
You can change it to release mode if you want to and that would solve the problem
but I recommend you to change between MSVC and MinGW and check which one is going to work.
Project->Build and Run-> and choose what you need.

Resources