gdb + qt: check variable content [duplicate] - qt

I just started using Qt and I wanted to debug my Qt application. Can I use the standard GDB debugger with Qt executables?

Yes you can. You might also want to use the gdb integration in Qt Creator, which does a much better job of inspecting data at run time than gdb alone.

There is no reason why you might not do so.
As Qt executables are just normal executables compiled by GCC you could debug them as all others.
The fact that the Qt build process auto-generates intermediate C++ files does not prevent this because those intermediate C++ files are just compiled normally together with your own files into the executable.

Yes, you can. First Google hit is this KDEbase tutorial.

Related

Build application and Qt from source using cmake

I'm trying to set up building an application that uses qt5.6 in a way that both qt and the application are build from source (using the ninja generator, with visual studio compiler on windows and clang on mac).
I'm stuck at find_package(Qt5Core ..) : when Qt is not build yet, it will not be found. And because it's not found, the generate cmake file is not complete.
I think I need a setup where it generates a ninja files that, when build, builds Qt and then regenerates the ninja file (and at this point it would find qt) before continuing the build.
Or any other way in which I can build Qt+application from source, so that if I change something in Qt, it is automatically rebuild.
How should I set up my cmake file(s) to do that?
You could use CMake's ExternalProject command to invoke CMake from within CMake. You can specify dependencies there, so that your application will only be built after Qt has been built.
I happend to have a small example here that uses ExternalProject_Add to build a library followed by an application. In that example, CMake for the library and the application is invokved at make time.
cmake_minimum_required(VERSION 3.0)
include(ExternalProject)
ExternalProject_Add(cmake_lib
URL ../cmake_lib
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
)
ExternalProject_Add(cmake_app
DEPENDS cmake_lib
URL ../cmake_app
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
)
The problem with Qt 5 is that it doesn't use cmake to get built, and thus your ninja build process won't know anything about the internals of Qt unless you tell it everything. E.g. if you change any dependencies of Qt, or if Qt gets partially built, you'd have to add a lot of knowledge to your project's build system to determine whether the Qt build needs to be invoked again. This can be certainly made to work in a "fire and forget" style of build, where the build always starts from scratch, like in a CI system. One quickly runs into serious trouble if the intent is to change Qt itself and re-run the build. Even Qt's own build system has serious trouble with full dependency tracking due to fundamental architectural decisions in qmake.
Qmake-based developer re-builds of Qt suck - and they do to such an extent that I didn't bother contributing to the project since it felt like a penance, where the simplest of changes to one source file would take a minute or more to rebuild on, and any changes to qmake project files would sometimes ballon into multi-minute affairs.
The only solution that I have found that actually works and doesn't make you hate life, the universe and everything, was to reimplement Qt's build and configuration system using cmake, so that qmake becomes unnecessary. As a result, a statically linked unity debug build of qtbase takes a couple of minutes with all features enabled - it's pretty zippy and is much faster than the fastest option provided by Qt 5 on Windows for MSVC builds: qmake+jom.
The Qt project endeavored to do this during Qt 6 development, and I believe that they were successful :)

QT application on BeagleboneBlack

Hi I have a debian image on BBB I have already installed QT creator on B^3 but the problem is whenever I try to start a new project in qt creator, couldn't see any option of kit. Infact when i add qmake and compiler path the application throws error.
What can I do to solve the problem. Can i directly get the full pack of SDK from qt.io/download ?
You must compile Qt libraries for your device (BBB) on your own, using specified compiler. You can find more information on this topic, here:
Qt Cross-Compilation Options
As soon as you compile Qt libraries for your device, you must move them to appropriate directories (on your BBB).
First, I would suggest learning to cross-compile, it's much faster & more easily maintained when you want to move to new versions. There's a ton of documentation and community around doing this. Windows & Linux both of which are probably dated, but info is still relavent. I've heard it's much easier from a linux host, but that could be biased.
That being said, if you don't want to cross-compile I believe you can simply install the qt embedded libraries. This question may offer some good advice. Once you have the libraries installed, you should be able to use qmake directly to create the Makefile for your project, then you can use cmake, or g++, etc.. to do the actual compiling.
You're likely going to work in command line though, I'm not sure you can run QT Creator on the BBB directly. I could be wrong.

Where to obtain qmake (QT) compiler for netbeans?

I would like to use netbeans 8 for make QT applications. How ever, I have to specify the qmake file, which is for compiling QT apps. Is there any official source where I can get it? I tried google a lot, but haven't found any normal place. Thanks for the help in advance.
qmake is a program that compiles Project Files (.pro) into a Makefile. Think of it as "autoconf" of Qt world. To compile a Qt project, you only need to perform 2 steps,
run qmake to generate a Makefile from the Project File (.pro)
run make to build your application
netbeans.org has a step-by-step guide how do set things up,
https://netbeans.org/kb/72/cnd/qt-applications.html
qmake is a Qt specific replacement for the make utility, not a compiler. It is part of the Qt distribution actually... Just checked here, yes, it is part of the libqt4-devel package. Note that obviously you need the Qt development packages in addition to the runtime Qt packages.

Which c++ compiler to use qt5 win7

trying to create a GUI for the first time.
I've decided to try QT 5.0, but it keeps giving me the error:
error: Qt Creator needs a compiler set up to build. Configure a
compiler in the kit options.
I go into kit options, and I can choose a number of different Visual Studio 11 compilers, or a MinGW compiler.
I have tried pointing the MinGW compiler to several different .exe files in the minGW bin dir, like c++.exe, gcc.exe, g++.exe, etc. I still receive the error message.
Then I read somewhere that I need to use MSVC10 to compile, however I can not find this compiler anywhere.
I just need to create a simple window with a couple labels and text boxes and a button, and I can't even get as far as creating a window.
Thanks for any help
I had to install MSVC2010, and use that compiler.
First configure a compiler in the "Compilers" tab of the "Build & Run" section in the Creator options. Then you can chose a configured compiler in a kit. Then set your project to use that kit.

C file in QT creator, and library issues

i work on windows environment, i have installed QT creator recently and wanted to execute a c program from .c file in QT. There are couple of problems why the file does not compile, first it does not recognize the library headers "time.h" "math.h" and even "stdio.h"
Two, i'm not sure if it will compile even after fixing the library, because i changed the include path in the .pro file to the path of the libraries. and still had a proble of compilation.
Is there a way, that the compiler knows that the file is .c instead of c++...how can i proceed.
Thank you very much
It sounds like you installed the IDE but not the SDK. The SDK comes with gcc and the standard libraries that you are referring to. If you need to use your own separate compiler, you can configure it in Qt Creator > Tools > Options > Build and Run > Tool Chains.
Some additional information may be found here for your issue:
http://www.qtcentre.org/threads/33974-Compiling-c-files-using-C-and-QT
So, my suggestion is to download the full SDK of Qt, and then pick and choose the elements you want, and make sure it includes a compiler.
Hope that helps.

Resources