I’m a summerstudent working on an existing code (C++) with Qt Creator. The goal is to embed a ROOT canvas within the Qt created application/program. There are two examples (similar to each other) that I’ve tried: qtcanvas from Github and qtcanvas from Gitlab.
If anyone experienced with ROOT and/or Qt knows what is breaking, or knows an alternative way implement ROOT in a QtWidget: your expertize would be greatly appreciated.
Both examples produce the following errors during compilation:
TCanvas.h: No such file or directory qtcanvas.hpp 13
TApplication.h: No such file or directory main.cpp 10
I’ve installed ROOT in /usr/local/ and used $ source /usr/local/root/bin/thisroot.h. ROOT works on terminal and the headers and libraries are in place. I’ve tried different versions of Qt and different compilers; they produce the same error.
I’ve managed to solve this bug for the older version of qtcanvas (github), by adding the following lines to CMakeList.txt:
This produced 62 errors concerning TString.h , for example:
'string_view' in namespace 'std' does not name a type TString.h 291
expected type-specifier TString.h 118
An example of compile output:
/usr/local/root/include/RConfigure.h:30:4: warning: #warning is a GCC extension
30 | # warning "The C++ standard in this build does not match ROOT configuration (201703L); this might cause unexpected issues"
| ^~~~~~~
/usr/local/root/include/RConfigure.h:30:4: warning: #warning "The C++ standard in this build does not match ROOT configuration (201703L); this might cause unexpected issues" [-Wcpp]
Thank you in advance,
Andrej
ROOT Version: v6.28/04 Platform: Ubuntu v22.04 Compiler: GCC v11.3.0, Clang14 and MinGW Qt Version: Qt v5.15.2 and v6.2.4
Maybe share with us what is the “Build Environment” (make a screenshot) of the corresponding tab in QtCreator and “CMake configuration”. There should be some include_path there pointing at the ROOT include headers.
Also, are the warnings just warnings, or are you getting a compilation error?
Out of the box, I get the message that the cpp and hpp file cannot be found. I’ve changed the .pro file to include the directories /src and /include. Same thing has been done in the code, e.g. #include "include\qtcanvas.hpp"
Thereafter I get the TCanvas.h and TApplication.h errors. I tried it now on Windows 10, which has the same Qt Creator as you (10.0.2), and the errors persist.
Please do no use any .pro file, just clone freshly the repository I mentioned. From QtCreator, open the CMakeLists.txt directly by clicking on File, Open File or Project, doble click on CMakeLists.txt.