Drawing TH2 slow on windows


I am trying to develop a Qt application using ROOT for plotting. Basically, the program will process the real time data, reconstruct a 2d image and draw it with “COLZ” option. I started from this code and simply replaced the TH1 histogram with a TH2 histogram in QMainCanvas::clicked1 method/slot. “Draw Histogram” button is connected to this slot for updating the histogram on button clicked. Eventually I need to replace this draw button with a timer and update the image every 0.5 or 1 second. Now the problem is that after pressing “Draw Histogram” button, it takes around 2 seconds to update the image, which is too slow and the gui can become unresponsive. The histogram has only 360x180 bins, and I am not sure why it takes so long to draw the histogram. My ROOT version is 6.24/00 built with Visual Studio 2019, Qt version is 5.15.2_MSVC2019_32bit and my system is windows 10.

For comparison, I compiled and ran the same code on Windows Subsystem for Linux (Ubuntu 20.04) on the exact same machine, with Qt.5.12.11_GCC_64bit and the same ROOT 6.24/00. It takes only 70-80 ms to draw the histogram, significantly faster than on windows. Is there a way for me to get a comparable performance on win10? I choose win10 because I need to run the data acquisition software and my application on the same machine at the same time for real-time analysis and the acquisition software only runs on windows 10.

Please see the full code attached below.


simple_canvas_2d.zip (4.4 KB)

Welcome to the Forum! Thanks for reporting the issue. We’ll investigate and report back.

OK, I can reproduce the problem. I’ll investigate more, but not sure we can do anything about it though. Qt & ROOT interplay is different on each platform and even don’t work anymore on some. The advised way is to use RCanvas in a QWebEngine. See for example Embedding ROOT GLviewer in QT - #3 by bellenot