Dear ROOT team,
I am trying to embed root GLviewer in QT. The objective is to be able to view a geometry within a QT application. I have seen the following post for embedding TCanvas in QT https://root-forum.cern.ch/t/root-and-qt5/19073/8 and I would like to do the same with GLviewer. Is there an example somewhere that I could use?
Thanks a lot for your help.
Dear ROOT team,
It’s not possible to embed a GLviewer in Qt. The given recipe is only valid for TCanvas. The only alternative is to use a Qt WebEngine together with JSROOT (see for example tracks and hits combined with ALICE detector). I’m sure @linev can give you more technical details about the Qt WebEngine
Yes, last years we developing web-based replacement for different ROOT components: RCanvas, RBrowser, RGeomViewer, REve, RFitPanel. They all using RWebWindow class. And any of RWebWindow-based widgets can be embed into qt5 application using QWebEngine class of Qt.
Just see how it is done in this tutorial: root/tutorials/webgui/qt5web at master · root-project/root · GitHub
It also demonstrates embedding of geometry viewer in qt application.
Thank you very much for your replies. I will carefully study the github files. What is the license regarding these code files? Is it possible to show the particles tracks within the geometry inside Qt with these examples?
Thanks a lot for your great help.
This example distributed with the ROOT sources under LGPL 2.1 license - see License - ROOT
Showing of tracks or hits is not implemented in RGeomViewer, but can be done relatively easy. Question is how complicated should be interaction with tracks.
There is REve component of ROOT, which is more powerful and includes much more features for showing event data and interacting with it. Please try event_demo.C example. With similar techniques it can be embed in qt5 application. It is evolving project and we can add new features relatively fast.
Thank you Sergey, that is very interesting what ROOT can do.
I have tried to compile ROOT via the following command:
cmake -DCMAKE_INSTALL_PREFIX=…/root-6.22.06-install/ -DPython3_EXECUTABLE=python3.8 -DPython2_EXECUTABLE=python2.7 -DCMAKE_CXX_STANDARD=14 -Dqt5web=ON -dwebgui=ON -Droot7=ON …/root-6.22.06/
I do not find the following files:
Am I missing something?
Maybe “-Dwebgui=ON” - you have small letter. Please check that
qt5web appears in list of enabled components at the end of cmake output
And example only works with latest ROOT from master branch.
It will be released soon as 6.24 version.
I followed your advice and compiled root from the master branch with the correct options. That is amazing what can be done in the browser with the examples inside eve7.
I also tried to compile the example qt5web. I added the following root libraries on top of the basic libraries:
-lROOTWebDisplay -lROOTGpadv7 -lWebGui6 -lROOTBrowserv7 -lROOTEve
Compilation works. However, execution gives me the following error:
Error in <TUnixSystem::FindDynamicLibrary>: libROOTQt5WebDisplay[.so | .dll | .dylib | .sl | .dl | .a] does not exist in /home/thomas/root-build/lib/:/home/thomas/Desktop/testRootGL/../../root-build/lib/:/home/thomas/Qt/5.15.1/gcc_64/lib:.:/home/thomas/root-build/lib:/lib/x86_64-linux-gnu/tls/haswell/x86_64:/lib/x86_64-linux-gnu/tls/haswell:/lib/x86_64-linux-gnu/tls/x86_64:/lib/x86_64-linux-gnu/tls:/lib/x86_64-linux-gnu/haswell/x86_64:/lib/x86_64-linux-gnu/haswell:/lib/x86_64-linux-gnu/x86_64:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu/tls/haswell/x86_64:/usr/lib/x86_64-linux-gnu/tls/haswell:/usr/lib/x86_64-linux-gnu/tls/x86_64:/usr/lib/x86_64-linux-gnu/tls:/usr/lib/x86_64-linux-gnu/haswell/x86_64:/usr/lib/x86_64-linux-gnu/haswell:/usr/lib/x86_64-linux-gnu/x86_64:/usr/lib/x86_64-linux-gnu:/lib/tls/haswell/x86_64:/lib/tls/haswell:/lib/tls/x86_64:/lib/tls:/lib/haswell/x86_64:/lib/haswell:/lib/x86_64:/lib:/usr/lib/tls/haswell/x86_64:/usr/lib/tls/haswell:/usr/lib/tls/x86_64:/usr/lib/tls:/usr/lib/haswell/x86_64:/usr/lib/haswell:/usr/lib/x86_64:/usr/lib Error in <[ROOT.WebGUI] Error /home/thomas/root/gui/webdisplay/src/RWebDisplayHandle.cxx:532 in static std::unique_ptr<ROOT::Experimental::RWebDisplayHandle> ROOT::Experimental::RWebDisplayHandle::Display(const ROOT::Experimental::RWebDisplayArgs&)>: Neither Qt5 nor CEF libraries were found to provide local display Error in <[ROOT.WebGUI] Error /home/thomas/root/gui/webdisplay/src/RWebWindowsManager.cxx:506 in unsigned int ROOT::Experimental::RWebWindowsManager::ShowWindow(ROOT::Experimental::RWebWindow&, bool, const ROOT::Experimental::RWebDisplayArgs&)>: Cannot display window in qt5 malloc_consolidate(): invalid chunk size
It looks like a problem with my Qt installation despite my success to execute other Qt applications. I will try tonight on a setup in which I did not install ROOT and QT locally unless you have any other idea regarding this error.
You need QWebEngine package of qt5 as well. On my platform it calls:
libROOTQt5WebDisplay library should be compiled once you enabled
Please check that you do not have error message like
Qt5 not found, disabling option 'qt5web' when running cmake.
Thank you Sergey, it worked perfectly. I will now try to embed REve component inside Qt, hoping it is not too difficult.
I have two last questions.
I have some difficulties to totally understand the difference between an RCanvas and a TCanvas, except that RCanvas is still experimental as of today and will be released later. It seems I should be able to plot exactly the same graph inside both of them and I have the same options.
Another point not totally clear to me is the difference between a TCanvas that I include in a QWebEngineView, as you showed me previously and a TCanvas that I include in Qt without a QWebEngineView, as shown in https://root-forum.cern.ch/t/root-and-qt5/19073/8. They are both the same ROOT object but act quite differently. For instance, the menus are different.
I know that’s quite basic questions but it is something unclear for me at the moment. Could you please help me to better understand?
RCanvas is an attempt to fully redesign functionality of TCanvas.
It made from absolutely different building blocks.
Primary goal of RCanvas - provide display of ROOT7 objects like RHist or RGraph.
But if one uses RCanvas to display “normal” TH1 or TGraph objects, it behaves mostly the same as TCanvas. I plan to provide some additional functionality with CSS-styling (which is supported by RCanvas), but do not have time yet to do this for TObject-derived classes.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.