Root and Qt5

Hi, is there any plan/schedule for a port of QtRoot to Qt5?
Thanks.

Hi,

No, nothing is planned for the time being.

Cheers, Bertrand.

There is an existing fork where porting of QtRoot-in-ROOT and Sourceforge QtRoot to Qt5 has been done for most important parts for 5.34 branch. While it’s not intended for actual use, it may provide some insight on what sort changes are needed. Actual code changes for QtRoot-in-ROOT part are pretty easy (it does not however work with Qt4, but should be easy to fix) but the needed cmake-changes are trickier. Sourceforge QtRoot, however, is a much bigger task particularly because it involves porting Qt3 code to Qt5 as Qt3Support-module present in Qt4 is not available in Qt5.

Thank you for the info. My problem is that I have been asked to produce a data monitoring GUI which should leverage the histogramming capabilities of Root and I would like to do it using Qt and QtRoot. But this has to run potentially also on platforms where only Qt5 is available (some recent OSX flavour), and must use a stable version of Root since my collaboration won’t allow the usage of unstable, out-of-tree packages.
I’ll take a look at the github and sourceforge code, but if there is still no plan to integrate its patches into the official Root tree then for me it’s a no-go…

Hi,

The best way is to use Qt, and embed ROOT in there. Bertrand knows how to do that :slight_smile: We should have a tutorial on this, too!

Axel.

[quote=“Axel”]Hi,

The best way is to use Qt, and embed ROOT in there. Bertrand knows how to do that :slight_smile: We should have a tutorial on this, too!

Axel.[/quote]
Yes, that’s what I actually did with Qt4 and wanted to do with Qt5. My question was about the possibility to build the necessary Qt part (e.g. libGQt) distributed with Root against Qt5.

Hi,

[quote=“Nicola_Mori”]Yes, that’s what I actually did with Qt4 and wanted to do with Qt5. My question was about the possibility to build the necessary Qt part (e.g. libGQt) distributed with Root against Qt5.[/quote]I don’t understand. libGQt is NOT needed to embed a TCanvas in a Qt application. And as I said, Qt5 is actually not supported by Qt ROOT (and there is no plan of porting it).

Cheers, Bertrand.

[quote=“bellenot”]Hi,

[quote=“Nicola_Mori”]Yes, that’s what I actually did with Qt4 and wanted to do with Qt5. My question was about the possibility to build the necessary Qt part (e.g. libGQt) distributed with Root against Qt5.[/quote]I don’t understand. libGQt is NOT needed to embed a TCanvas in a Qt application. And as I said, Qt5 is actually not supported by Qt ROOT (and there is no plan of porting it).

Cheers, Bertrand.[/quote]
Sorry to bother and also to go off topic, but my Qt4 application embedding TCanvas actually needs libGQt. I embed the TCanvas by creating a TQtWidget and getting the canvas with TQtWidget::GetCanvas(). Doing so, I need to link libGQt to my executable, otherwise compilation fails with:

CMakeFiles/SimViewer.dir/MainWindow.cpp.o: In function `MainWindow::ProcessEvent()':
/home/mori/analysis/CALET/caletSW/SimViewer/src/MainWindow.cpp:639: undefined reference to `TQtWidget::Refresh()'

and similar errors. Maybe I’m embedding the TCanvas in a wrong way?
BTW I understood the Qt5 situation, thanks again.

Hi,

Could you try the following example and let me know if it works for you?simple_canvas.tar.gz (2.57 KB)
Cheers, Bertrand.

Hi, the example works perfectly (I only had to to configure the project with “qmake -qt=4 canvas.pro” since on my system both Qt4 and Qt5 are present, and add a minor tweak to the .pro file since I use an installed version of ROOT so headers and libraries are in $ROOTSYS/include/root/ and $ROOTSYS/lib/root/, respectively). If I understand correctly the QRootCanvas is a native Qt widget embedding a TCanvas, and the TCanvas is drawn inside the widget by leveraging TVirtualX. Correct?
I didn’t know about this method, the ROOT user guide only mentions TQtWidget and QRootCanvas seems to be not part of the current ROOT tree. Will QRootCanvas be available within ROOT mainline, or alternatively can I use the code you sent me in my project?
Thanks.

[quote=“Nicola_Mori”]If I understand correctly the QRootCanvas is a native Qt widget embedding a TCanvas, and the TCanvas is drawn inside the widget by leveraging TVirtualX. Correct?[/quote]Correct.

[quote=“Nicola_Mori”]Will QRootCanvas be available within ROOT mainline, or alternatively can I use the code you sent me in my project?[/quote]It will not be part of ROOT, and sure, feel free to use the code I sent, it is just a very simple example showing how easy it is to embed a TCanvas in a Qt application…

Cheers, Bertrand.

Thank you very much, Bertrand. By the way, the QRootCanvas works also with Qt5 so this completely solves my problem, since my only purpose was to embed a TCanvas in a Qt program!

Good to know, thanks for the information!
And BTW, this method works for any kind of foreign application/toolkit, as (shortly) described here.

Cheers, Bertrand.

The QRootCanvas works beautifully, except for spamming the terminal with messages like:

[quote]Warning in TCanvas::ResizePad: Root Canvas height changed from 32000 to 10
Warning in TPad::ResizePad: Root Canvas_1 width changed from 0 to 10[/quote]

I create the TCanvas inside the QRootCanvas with:

  setAttribute(Qt::WA_PaintOnScreen, true);
  setAttribute(Qt::WA_OpaquePaintEvent, true);
  setMinimumSize(10, 10);
  setUpdatesEnabled(kFALSE);
  setMouseTracking(kTRUE);
  int wid = gVirtualX->AddWindow((ULong_t) winId(), 10, 10);
  fCanvas = new TCanvas("Root Canvas", width(), height(), wid);

This with Root 5.34.25 and Qt 4.8.6. Does anyone know the reason of these messages and eventually how to remove them?

By the way, with Qt5 I obtain different messages:

[quote]QWidget::paintEngine: Should no longer be called
QWidget::paintEngine: Should no longer be called[/quote]
which are annoying as well…

Regarding the Qt5 messages in case of technical interest, I examined the cause some time ago and had made following observations:
“QWidget::paintEngine: Should no longer be called.” gets triggered in TQtClientWidget constructor from line
QWidget::setAttribute(Qt::WA_PaintOnScreen);
when creating an empty native ROOT-window which has no Qt-implementation (for example fit panel). Also creation of TCanvas causes creation of TContextMenu, which in turn will lead to TQtClientWidget.

Hi Betrand,

sorry to dig this old topic up again, but it seems this still is the best example code for embedding a ROOT canvas in Qt up to now :wink:.

I am right now converting several application form Qt-ROOT to this method to get rid of any use of Qt-ROOT in our framework.

There are many many improvements from using this method, so thanks for recommending it!

However, there are also several drawbacks:

  • Transparency does not work anymore (since the X11 backend does not support that). Is it possible to embed a Gl-Canvas similarly? I failed when trying to copy some code from TRootEmbeddedCanvas to activate this.
  • If there are many plots e.g. on different tabs, the initial widget drawing takes quite long compared to Qt-ROOT (since Qt-ROOT had a pixmap for additional double-buffering, and the embedded canvas does an opaque paintevent). Is there a way to speed this up?
    I believe both QWidget and also the regular TVirtualX can double-buffer, but I guess both have to be off for embedding to work correctly?

EDIT: Actually, one more, but much less important. Mouse wheeling does not work, and I am unsure how to pass through this mouse event correctly (but this also did not work with Qt-ROOT).

Cheers and thanks a lot for your example code,
Oliver

Hi,

I compiled and run Bertrand’s example “simple_canvas.tar.gz” with success with QtCreator under my Linux ditribution So I tried to do the same thing under Windows.

I compiled root 5.34.34 with VS2010 using Cmake-3.2 and enabling qt, I have also Qt-4.8.1 -VS2010 binary.
I’m able to compile with success Bertrand’s example, when I run it the main window appears but if I press “Draw Histogram” nothing happen, no error nor histogram.
I tried to debug the code with AtCreator but everything seems to be fine… but I don’t see histogram…

Any idea?

Thanks
Alberto

I remember often seeing kind of refresh-problems on some combinations of (Windows, ROOT, Qt, QtRoot), in which the blank screen would get something painted on it only after e.g. resizing the window. If that doesn’t help in this case perhaps increasing gDebug would tell more about the problem. Another experienced problem causing similar symptoms is that for some reason a painter plugin fails to load.

Hello,

I was having issues with ROOT and Qt. I inherited a monitoring GUI that embeds TCanvas into a Qt application and initially was unable to run due to libGpad errors which seems to have been fixed after re-configuring ROOT with X11 enabled and Cocoa disabled (I am on Mac OSX 10.10). To test whether the Gui is working I have tried the “simple_canvas” application pointed to above.

I am using Qt 5.6 and Root 5.34/34. In order to compile this application (simple_canvas) I have had to ad Qt+=widgets to the *.pro file and also I have had to remove the dependency on the library RGL (so I have removed the “-lRGL” from the LIBS in the *.pro file) as this library was not found in my ROOT lib/ directory.

When I run the application, the window opens but the canvas is entirely black (attached as “simple_canvas_gui”)


although when I save the canvas as an *.eps file I see the histogram and canvas has actually been drawn (attached as “test.eps”) test.eps (9.84 KB).

My console is also flooded with the Errors reported previously:

Error in : BadWindow (invalid Window parameter) (XID: 2506113776, XREQ: 2)
Error in : BadDrawable (invalid Pixmap or Window parameter) (XID: 2506113776, XREQ: 62)

My main concern though is the fact that the histogram/canvas is not shown when the application is running. Is this due to the library RGL missing (I am not entirely sure what this library is) or due to something that needs to be set (openGL) for Mac OS?

Any help is greatly appreciated, and many thanks!

HI dantrim,

I have met the exact same problem as yours, have you figured it out?

Thanks,
Yi