How to generate compile_commands.json with QT project? - qt

I'm not familiar with QT but have to work with a QT project(.pro) recently. I hope to generate a compile_commands.json for this project, so I can read codes inside emacs's lsp mode. Unfortunately, I cannot find any way.

Build/Generate Compilation Database for "yourprojectname"

Related

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.

Is there any basic tutorial on how to compile software from source under windows

I'm a beginner on open source world.
I can compile my own C++ code in VS 2015. but, I have little knowledge about compiling open source code. I can't even find a project file of that.
Anyway, I'd like to compile Sigil 0.9.4 version from source. My system is Windows 10 64 bit, and Qt 5.6.0 is installed. I've been looking for any basic guide for that but I haven't found yet.
I have downloaded a source code zip file from the link
https://github.com/Sigil-Ebook/Sigil/releases
And I have no idea what's the difference between Sigil-0.9.4-Code.zip and Source code (zip).
Which one should I download to compile?
Intuitively, I used 'importing project' in Qt but I get message 'no rule to make target all. stop'
Any instructions for that?
Thank you in advance!!!
For compilation you will need to use CMake. I recommend going through their web-site and read about it.
If you look at the source repository of the software you are trying to build (Sigil), you will see the root folder contains CMakeLists.txt. This is the file that will tell cmake program how to build and configure the software.
If you are planning to use Qt as your IDE, I recommend to download and install cmake first. Then make sure, Qt's toolchain is set up properly with the cmake. Then all you have to do is to open that CMakeLists.txt in Qt (see more details in the aforementioned link). Also, you can find plenty other tutorials on how to use cmake to compile your projects.
Hope this will help you get started.

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.

Adding Qt Sources to QtCreator 2.4.1

I am currently using QtCreator 2.4.1 with Qt 4.7.4 development libraries (in Ubuntu) and am trying to track down a bug which after profiling with valgrind seems to occur internally within QGraphicsView::paintEvent(…) method
To help isolate this problem I would like to step into the Qt sources. Having done some searching through both the Qt forums and stack overflow and have not being able to find a way to integrate the sources with my version of QtCreator.
I have currently tried downloading the sources via the QtSDK manager and adding a “Source Path Mapping” within Tools->Options->Debugger. I am sure that this step is where I am making a mistake as I am unable to even switch to source when viewing internal Qt header files i.e. from QGraphicsView.h
I have so far tried adding the following Source Path Mappings
Source Path=/var/tmp/qt-src
TargetPath=/home/paul/QtSDK/QtSources/4.7.4
and
Source Path=/var/tmp/qt-src
TargetPath=/home/paul/QtSDK/QtSources/4.7.4/src
Neither works.
I have also tried building Qt directly from source, adding this to my "Qt versions" list within Qt Creator and creating a new project configuration using this version. This also did not work.
Likewise I have tried adding the src folders to my gdbinit file. This also fails to work.
I am completely lost with this.
Paul
Someone asked a similar question here: Need to step into Qt sources (my IDE is Qt Creator).
Someone else asked about Valgrind errors with Qt here: Suppression files for Qt memory leaks with Valgrind
And here is a little more info about Using Valgrind with Qt Creator along with some explanation about how to read the results. Its a little dated from late 2010.
Related Suggestions
I wouldn't debug the QGraphicsView class just because of all the effort to make it work or find the problem might be for nothing... Qt is moving to using the SceneGraph as the backend for QML and the rendering engine for QGraphicsView might become obsolete.
Updating to the latest stable build of the Qt libraries may make a big difference for QGraphicsView.
If you post the valgrind error you are getting to the Qt Trolls, someone might be able to explain what is going on for you.
There are other debugging techniques besides the traditional debugger. I've been programming in Qt in Windows (without valgrind) and with a large multi-threaded application, that loads a bunch of Dll's. I've had to put some faith into the Object Tree Model clean up and work on all the new calls I put in. Most of the time I just use QDebug to find errors. Then I am also using a combination of qInstallMessageHandler() with QDebug to implement decent logging for the hard to track bugs.
See also Qt Debugging Techniques.

OpenCV in Qt Creator

Since I am very UNHAPPY with Visual Studio (It's just Junk!) I am trying to use Qt Creator, which seems to be the solution for my c++ projects to get easily run in my Mac also.
But I am using OpenCV. So, How do I set libraries in Qt?
(include folder and maybe some libs)
I am trying with this app:
http://www.qt-apps.org/content/show.php/Qt+Opencv+webcam+viewer?content=89995
But getting many errors since Qt does not know where to find the libraries, where should I enter the paths or something?
Help will be very well appreciated.
Ignacio
I think I have answered 2 Qt questions that recoup what you are asking :
The first answer is about OpenCV integration in Qt: OpenCV with other GUI (like Qt or WxWidgets) on Win32 VC++
And the second about using 3rd party libraries in Qt: How do i reference the qjson.dll file from my qt project?
I know that this is an old thread but this answer might help anyone on unix trying to link to OpenCV 2.3.1 +
It is actually quite simple with pkgconfig. All you have to do is in your qmake file *.pro add the following:
unix {
CONFIG += link_pkgconfig
PKGCONFIG += opencv
}
Thats it if you are on a unix based system.
Warning, the answers above are deprecated & misleading. Just set up your project with CMake, just like opencv 2.x itself is. Then you just set CMake to add $OPENCV_LIBS as a library to link to and you're done. In qt creator, file-->open project and open the CMakeLists.txt file, presto.
Don't use qmake or pro files unless you really want a QT gui. Even then, look at the QT samples in opencv 2.2+ first, I think they use cmake to handle the qt interface.
Partial answer to myself:
See qmake project files, declaring other libraries.
But I think I will have to compile OpenCV for Linux as I don't think opencv.framework will work with LIBS.
Is there any variable like FRAMEWORKS?

Resources