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

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.

Related

How to disable QML Debugger in Qt Creator entirely?

How can I disable QML debugging in QtC entirely? I can disable it from the run settings, but for some reason it is always switched (back) on.
I do not use QML in the UI, but I use the JavaScript engine for other purposes (pure guess, is that why it is always "on"?). But I entirely want to disable QML debugging, as this always "hangs" and is not needed (at my place).
How can I do that?
I can uncheck "Enable QML" but is always checked "on" again when I restart QtC.
Uncheck the option Enable QML debugging and profiling from the Build Steps in the Build Settings
Just some details:
You are correct it is here, when I check QML CONFIG+=qml_debug is added to the cmd line. Wonder if the CONFIG-=qml_debug in the .pro reverts that(the idea is good)
P:.....in\qmake.exe H:\Pr...pro -spec win32-msvc "CONFIG+=debug" "CONFIG+=qml_debug" && P:/Qt/Tools/QtCreator/bin/jom.exe qmake_all

Why I cant debug qml from qt creator?

I installed the last Qt 5.12.2 . Then I open the cmake project via Qt Creator.
First I see a huge count on the intellisence issues: from "udeclared identifies of nullptr" to errors with each type "unknown type name".
The build proceeded successfully and I receive correct binary.
But any breakpoint marked as "Unclaimed breakpoint" and I cant debug any .qml (the .cpp could be debug)
So why it happens and how to debug the QML? (this future is still supported?)
UPDATE: The "QQmlDebuggingEnabler enabler;" and "doc.qt.io/qt-5/qtquick-debugging.html" doesnt helps :(
UPDATE2: #Amfasis -
I created a CMake-based Qt Quick project, and it shown that it supports QML/JS debugging. I checked the CMakeLists.txt, and found one relevant line:
target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
So I think if you'd like to debug your CMake-based Qt Quick project, you should also add this line to your CMakeLists.txt.
And don't forget to check on enable QML in the project setting within the sector of debugging setting.

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/

QtCreator Designer signal/slot connections inconsistent with generated code

I'm working on a Qt project in QtCreator. The project has a dialog box with several UI elements, some of which have to be enabled/disabled according to what the user does. (i.e. If the user selects a radio button, then the form field has to be enabled.)
When I add a new signal/slot connection or delete an existing through the Qt Designer tool, the change shows up just fine in the preview. When I compile the application, though, the window still behaves exactly as it did before.
I investigated this by checking out the ui_WindowName.h file that the Qt Designer creates. Near the end of the setupUi function is a set of connect() calls. These connect() calls are consistent with the slot and signals that existed earlier today, but they do not reflect the changes I have made through Qt Designer since.
If I manually change the ui_WindowName.h file, then the UI works. But, of course, my changes get overridden if I ever try to chance anything from Qt Designer.
Even when I quit QtCreator and open it again, the Designer still shows the changed slot/signal connections while the auto-generated code does not reflect the changes.
Am I doing something wrong? Is there some way to delete whatever cache the Designer is storing or something to get things back in sync?
Thanks!
(One other thing: I'm using the stand-alone Qt Creator, not trying to develop in Visual Studio. The only other similar problem I could find on the web was from someone developing in Visual Studio, which doesn't support the automated signal/slot stuff.)
As usual, the answer is obvious once you realize it.
I moved the project in the course of working on it. There's a .pro.user file that keeps track of where the project is located. Without realizing that, I moved it along with the rest of the files.
As a result, I was editing one copy of the project and running the other.
The moral of the story: If you move a Qt project, remember to update your .pro.user file.
(Or you can just delete it. Qt Creator will prompt you to re-create it when you open the project.)

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