How to compliment existing ROOT install with Qt?

Hi Everyone,

I am trying to use a few root objects in my Qt project, I thought just including root libraries would be enough but seems like life’s way more complicated than that ! Although I found a solution (sort of) here: http://root.bnl.gov/QtRoot/How2Install4Unix.html#complement, which doesn’t require a fresh “root installation with Qt enabled” ! Because I really don’t want to install root again !

Here’s what the link says:

Of course I replaced step-1 and 2:

export QTROOTSYSDIR=`pwd`/qtrootsys
export QTROOTSYSDIR=$ROOTSYS

then I proceed to the 5th step, qmake produces the following output:

me@me/QtRoot/qtRoot$ qmake
Project MESSAGE: excluding
Project MESSAGE:  Installing <qt qtgui qtgl qtthread qtimage qtroot qt4ged> of QtRoot system
Project MESSAGE:  To remove some packages from the build, start the qmake utility as follows:
Project MESSAGE:  
Project MESSAGE:  > qmake QTPACKAGES -= <list of unwanted packages>
Project MESSAGE:  
Project MESSAGE: type <make install> - to install qt qtgui qtgl qtthread qtimage qtroot qt4ged of QtRoot into </home/me/root> directory
Project MESSAGE: 

and then I ran make that failed badly ! The output is huge so I am attaching a txt file here: makeOutput.txt (21.3 KB), but I am pasting below the last few lines that states the exact error:

[code]
src/TQtContextMenuImp.cxx:17:22: fatal error: QWebView: No such file or directory
compilation terminated.
Makefile:1437: recipe for target ‘.obj/TQtContextMenuImp.o’ failed
make[1]: *** [.obj/TQtContextMenuImp.o] Error 1
make[1]: Leaving directory ‘/home/me/QtRoot/qtRoot/qtgui’
Makefile:81: recipe for target ‘sub-qtgui-make_default-ordered’ failed
make: *** [sub-qtgui-make_default-ordered] Error 2

[code]

How can I make this [quote]Complement the existent ROOT installation with QtRoot plugin[/quote] work ?

Additional info:

  1. I already had a Qt 5.7.1 (not root QT) installed on my Ubuntu 16.04 (64 bit) system.
  2. My ROOT version is 5.34/36.

Might be related:
What exactly is this: http://packages.ubuntu.com/xenial/root-plugin-gui-qt ?

Hi,

QtROOT (and QtGSI) are deprecated. The simplest way of using Qt & ROOT together (without any extra plugin) is to embed a TCanvas inside a QWidget. Just try this very simple example: simple_canvas.tar.gz (2.56 KB)

[bellenot@bbcc7x64 test]$ tar -zxvf simple_canvas.tar.gz
simple_canvas/
simple_canvas/canvas.cxx
simple_canvas/canvas.h
simple_canvas/canvas.pro
simple_canvas/main.cxx
[bellenot@bbcc7x64 test]$ cd simple_canvas/
[bellenot@bbcc7x64 simple_canvas]$ qmake-qt5
[bellenot@bbcc7x64 simple_canvas]$ make

[quote=“quantatanu”]Might be related:
What exactly is this: packages.ubuntu.com/xenial/root-plugin-gui-qt ?[/quote]
No idea.

Cheers, Bertrand.

Hi Bertrand, thanks a lot for replying. I have problems with the example code, the compiler can’t find any of the libarry files:

:-1: error: cannot find -lCore
:-1: error: cannot find -lCint
:-1: error: cannot find -lRIO
:-1: error: cannot find -lNet
.
.
.
etc

all though I have no problems with libraries (root or not) when I am working without Qt.

As described here, you have to set the necessary environment:

[quote]For the sh shell family do: . /root/bin/thisroot.sh
For the csh shell family do: source /root/bin/thisroot.csh
where is the location where you unpacked the ROOT distribution.
[/quote]
Cheers, Bertrand.

Hi, I think my environment variables are ok because I can operate root from anywhere and also compile various codes involving root libraries using "g++ `root-config --libs --cflags --ldflags` ..." etc. Still for the sake of absolute certainty, I am setting the links to the absolute location:

INCLUDEPATH += /home/me/root/include/
LIBS += -L/home/me/root/lib/ -lCore -lCint -lRIO -lNet \
        -lHist -lGraf -lGraf3d -lGpad -lTree \
        -lRint -lPostscript -lMatrix -lPhysics \
        -lGui -lRGL 

and this produces the following error (massive) report: errorreport.txt (19.7 KB), which is even worse than the set up you gave me originally ! I am guessing, it has something to do with the actuall compile command that the Qt is using… somehow it’s not including root-config --libs --cflags --ldflags, can you please tell me how can I implement g++ root-config --libs --cflags --ldflags equivalent in Qt .pro file ?

Thanks
-atanu

Did you try the simple example I sent?

[code]TEMPLATE = app

QT += widgets

CONFIG += qt warn_on thread

INCLUDEPATH += $(ROOTSYS)/include
LIBS += $$system(root-config --glibs)
HEADERS += canvas.h
SOURCES += canvas.cxx main.cxx
[/code]

[quote=“bellenot”]Did you try the simple example I sent?[/quote] yes, I am trying to compile your code. After implementing the changes in the .pro file, that is replacing everything by:

TEMPLATE = app

QT += widgets

CONFIG += qt warn_on thread

INCLUDEPATH += $(ROOTSYS)/include
LIBS += $$system(root-config --glibs)
HEADERS += canvas.h
SOURCES += canvas.cxx main.cxx

I now get these errors: errorreport2.txt (4.53 KB), something wrong with the way I am implementing the “root-config”.

But when I run “root-config --glibs” in my terminal I get:

-L/home/me/root/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic

So I guess my root-config is fine… somehow the Qt doesn’t understand it ! Please note that my Qt is a separate install… it has nothing to do with Root… it’s not Qt ROOT or anything.

Well, it works for me, so you could try to explicitly write (in your .pro file) the list of libraries given by ‘root-config --glibs’…
And it works with a regular ROOT version (no Qt) and regular Qt (no extra plugin)

Cheers, Bertrand.

It works ! Here’s how the project file looks like:

TEMPLATE = app

QT += widgets
CONFIG -= moc

HEADERS += canvas.h
SOURCES += canvas.cxx main.cxx

LIBS +=-L/home/me/root/lib -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic

INCLUDEPATH += -I/home/me/root/include

although it looks kinda same… as the one you originally suggested… wondering why didn’t it work earlier ! But anyway thanks so much for helping.

Dear Bertrand, all

I would like continue this thread and asking next question, since you simple_canvas example works well when trying to build an app on qt5 and embed root canvas. However, I see a limitation, which I cannot workaround. Here is my question… When I create an object of QMainCanvas in the same scope as TApplication is, everything is fine, unless I want to create such QMainCanvas within the nested scope. Everything is fine when compiling, however the canvas simply doesn’t appear/draw. What is the reason of that?

Thanks in advance for help!
Bartek

Hi Bartek,

I’m not sure to understand the problem you have… Could you post a running piece of code showing the issue?
(and note that you should open a new topic instead of posting on an old one…)