Qt based application with QtROOT using CMAKE

Dear QtROOT experts,

I’ve been spending the last days to set up a new GUI project based in Qt and QtROOT. After a lot of struggles finally everything seems to be fine, except one last technical thing:

To have one common build system for the rather large project I am using cmake (the GUI is set up using designer, the .ui XML files are converted by a cmake plugin into classes and inherited for the actual implementation). I have installed the BNL QtROOT extensions since I never got the built-in QtLayer stuff to work correctly (context menus never worked, for example).

I can compile everything and I get a nice UI containing a TQtWidget. However, I cannot draw anything in the canvas, nor can I change its properties (e.g. SetBorderMode()):

TestQtGUI::TestQtGUI(QWidget* parent) : QMainWindow(parent) { TCanvas* canv = fTQtWidget->GetCanvas(); canv->cd(); canv->Update(); TH1D* hist = new TH1D("bla","blub",100,0,10); hist->Draw(); canv->Update(); canv->SetBorderMode(0); canv->Update(); canv->Dump(); }

The calls are simply ignored, except for the Dump() though - I can see the text output. Clicking the Widget and setting e.g. the BorderMode manually works as well. Please excuse the abundance of Update() calls, they are there just in case :slight_smile:

If I take the code just for the TQtWidget and compile it with qmake (like in chapter 26 of the ROOT documentation) including the rootcint.pri everything works.

Somehow I seem to get a wrong pointer to the canvas… Or could this be some nasty dictionary thing? Am I overlooking something extremely trivial? Is some elementary call missing?

Thanks in advance for the support


I was really stupid and created a wrong object type in my main…

All problems are solved - for now :slight_smile:

Kind Regards


But … RULE OF THUMB, PLEASE [-o< do not do [-X anything special :exclamation: within the widget class ctor (especially UPDATE/Draw. The “update” will be called :bulb: for you as soon as the system is initialized and ready automatically ). It is the race condition prone approach. Make it as simple #-o as possible, Just set your GUI layout up. That’s. It will save =D> you enormous amount of error hunting time. (with/without ROOT ). Search this forum for examples.