Qt as IDE for ROOT

Hello everyone,

I am just starting with ROOT, so I guess you all know how challenging can be, at least, it’s been my case! I was wondering if someone has tried to use Qt as an IDE for ROOT and if yes, could you please shed some light on how to do this process??

I’d appreciate all your possible help!!
Thanks a lot in advance!

Art2

Qt is a framework for many things, but it is not an IDE.

Are you talking about “Qt Creator”? If you have a working cmake project, you can just open the CMakeLists.txt and it works perfectly (I don’t remember, probably I had to add an include path for root or source thisroot.sh first?) Anyway, it works.

You can also try KDevelop 5. It is also Qt based.

If you want non-Qt IDEs, try Visual Studio Code (with C++ IntelliSense extension) and/or Eclipse (with CDT).

It is up to you what you prefer. You need to know your editor anyway.

Usually the only thing you need to do is point the IDE to the ROOT header file include path.

Hi!

Thanks a lot for your reply. Sorry for not being precise, yes, I mean Qt Creator. I have worked with Qt creator before, coding own programs, and I had to include some external libraries and includes in the project. However, Root uses a large number of libraries and to include them by hand doesn’t look reasonable. I have a local installation of Root, so I guess I have to give both, the include and the library path.

Can you tell me how to do this …

Usually the only thing you need to do is point the IDE to the ROOT header file include path.

for all the root libraries and includes?? is this even possible??

Thanks!

Art2

Hi Arturo,
after installation, all libraries are in $ROOTSYS/lib and all headers are in $ROOTSYS/include
where $ROOTSYS is the path to your ROOT installation.

Hi,

Thank for the reply, I am aware of this, by doing
root-config --libs
and
root-config --cflags I can find where they are. The question would be, how to let Qt Creator know where they are. Any idea?

Thanks once more!

Hi,
this is more a QtCreator question at this point, but a quick google search brings up the editor’s guide:
http://doc.qt.io/qt-5/third-party-libraries.html

and a stackoverflow answer:

It seems you need to edit your *.pro project file to add the relevant directories to the INCLUDEPATH and LIBS variables.

Hope this helps.
Enrico

I do it like this:

  1. Create a new plain C++ project with CMake
  2. Quit QtCreator
  3. source thisroot.sh
  4. mkdir project/cmake/Modules directory
  5. copy root/etc/cmake/FindROOT.cmake to your cmake/Modules directory
  6. Modify CMakeLists, add something like this
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Wextra")

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
include(FindPkgConfig)

find_package(ROOT REQUIRED)
include_directories(SYSTEM ${ROOT_INCLUDE_DIR})

And for your executable, add target_link_libraries(your_executable ${ROOT_LIBRARIES})

Then restart qtcreator from the shell where you have already sourced thisroot.sh and be happy.

Hi again,

It worked, I mean, now it recognizes everything and does the build and debug without problems. However, I think there is still something I’m missing. I’m not getting any “ROOT output”, like the plots. I used this code here https://root.cern.ch/doc/master/candledecay_8C.html and as I said, everything worked except by the fact that nothing is shown.

I have the feeling that at some point I am not calling ROOT, like @behrenhoff quoted in his post. Do you have an idea?

Thanks to both!

Hi,
maybe this answer can help:

Cheers,
Enrico

1 Like

Hi Enrico,

It worked!!! Thanks a lot!!!

Cheers,

Art2

You can check out here how to setup QtCreator IDE to build and debug ROOT scripts here: