I have a question, before I spend more time digging into it.
When I saw there is a Qt layer and that you can embed TCanvas in QWidgets I thought: “Great!!!”
The thing didn’t last too long, because when I looked into the example, it seems you have to run TRint instead of the Qapplication. That is not to nice, since I have my Qt program and I want to include TCanvases with the minimum possible impact. I still want my main to call QApplication. Now the question is if I can include canvases like that.
If it isn’t posible please let me know so I don’t spend much time trying in vain.
I tried that and it worked. Now a question out of curiosity:
Isn’t it possible to do it without having to create the TQApplication? I mean using QApplication… does it have to do with the fact that Root runs the Qapp in a thread other than the main thread? because one would naively think that the canvas class that inherits from QWidget shouldn’t have to know anything about the innerworkings and all the communication with the gui thread is implemented somewhere else.
Later, if the histograms use this class instead of the standard canvas class they don’t know what goes behind the scenes. That allows gui changes and all in a transparent way (isn’t it one of the nice thigs of C++?).
I have a question, before I spend more time digging into it.
When I saw there is a Qt layer and that you can embed TCanvas in QWidgets I thought: “Great!!!”
The thing didn’t last too long, because
when I looked into the > example, it seems you have to run TRint > instead of the Qapplication.
The answer is "Yes and “No”.
No, you can create QApplication on your own. Even more you can KApplication if you are goinmh to use KDE Widgets.
Yes, However to use ROOT you still need to create TRint.
I hope it is clear. What really happens TRint just saves you some time by creating QApplication internally.
That is not to nice, since I have my Qt program and I want to
include TCanvases with the minimum possible impact. I still want
my main to call QApplication.
Now the question is if I can include canvases like that.
No problem with your main, but to use TCanvas you have to have TRint as well. You have to create it at some point.
If it isn’t posible please let me know
so I don’t spend much time trying in vain.
It is possible,
If you have hints please let me know as well.[/quote]
aYou can pick the Qt project, where the “main” is the that created automatically by Qt designer and it contains NO ROOT dependency.
(see: root.bnl.gov/QtRoot/QtRoot.html#designer) to pick the project)
I got the thing working with Qt Designer and everything
I just wrote my own little class to modify the way the canvas is created and it is fine.
I’m actually trying to run QApp in a separate thread, so it’s funny you mention it Valeriy. The only problem seems to be when there is a QEvent so I was thinking of doing some sort of “registration” of the classes and making the QApp instanciate the widgets (like a manager).
[quote=“javierggt”]I got the thing working with Qt Designer and everything
I just wrote my own little class to modify the way the canvas is created and it is fine.
[/quote]
I think with the current version of TQtWidget one would not need to modify the TCanvas. (thanks this discussion. Such essential functionality was missed indead)
Just a comment about Qt thread. The Windows version does use the separate Qt Gui thread and it does send messages from one thread to another one. My feeling one will need it to run Qt layer with the “native” Mac interface also.
For further infromation just look up the code from your $ROOTSYS/qt directory.