TQtWidget Qt and Root

Valeriy,

What I was trying to comment on in my last e-mail was the fact that I noted that cint seems to start when invoking a TQtWidget object. This appears to arise from the fact that in the constructor there a TRint object is instantiated. I noticed that by setting fembedded=0, this call is not performed and cint not started. However, I don’t really understand the other effects of changing this parameter since there is no documentation. Can you fill me in on what this is about and whether it is ok to set to 0 if I don’t want Cint when using Qt with root?

Also, I noticed that you had a log discussion with javierggt about similar issues. That is he wanted to have a pure qt application and not run TRint. It seems he resolved the problem, but it is not clear from the post exactly how this was done. Can you elaborate on this? I am attaching the conversation you had with him below.

Thanks in advance.

Jon

Post of: Javierggt

javierggt

Joined: 03 Sep 2003
Posts: 19
Posted: Sun Aug 08, 2004 17:38 Post subject: Qt layer and QApplication


Hi all,

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.

If you have hints please let me know as well.

Back to top

Valeriy Onuchin

Joined: 27 Aug 2003
Posts: 300
Location: CERN,IHEP
Posted: Mon Aug 09, 2004 13:35 Post subject:


Hi
check www-linux.gsi.de/~go4/qtroot/html/qtroot.html

Regards. Valeriy

Back to top

javierggt

Joined: 03 Sep 2003
Posts: 19
Posted: Mon Aug 09, 2004 16:19 Post subject:


Thanks Valeri for your reply.

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++?).

again, thanks for your reply.

Javier

Back to top

fine

Joined: 03 Sep 2003
Posts: 79
Location: BNL / Upton, USA
Posted: Mon Aug 09, 2004 23:55 Post subject:


With Qt layer it is possible to mix any Qt and Root widgets

See:
root.bnl.gov

root.bnl.gov/QtRoot/QtRoot.html#embed

You can find an example of the “normal” working Qt project there

root.bnl.gov/QtRoot/QtRoot.html#designer

You still have a question just drop me a message
to clarify your needs and Qt layer capabilites.



Hope this helps
Valeri Fine

Back to top

fine

Joined: 03 Sep 2003
Posts: 79
Location: BNL / Upton, USA
Posted: Tue Aug 10, 2004 0:06 Post subject: Re: Qt layer and QApplication


javierggt wrote:

Hi all,

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.



Hope this helps
Valeri Fine

Back to top

fine

Joined: 03 Sep 2003
Posts: 79
Location: BNL / Upton, USA
Posted: Tue Aug 10, 2004 3:07 Post subject: Re: Qt layer and QApplication


[quote=“fine”][quote=“javierggt”]

Hello
I’ve realized I was not correct answering your question.

The right answer of your question,

"Now the question is if I can include canvases like that. "

is

Yes, you can period.

I made one line correction of my code (thanks this discussion to bring things up)

You can pick the last version of Qt layer
root.bnl.gov/QtRoot/QtRoot.html#source
This correction will be included into the ROOT CVS also.
However the BNL CVS allows you to update the Qt layer of your ROOT production version (which is 4.00.08a at the moment)
(see: root.bnl.gov/QtRoot/QtRoot.html#install )

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)



Hope this helps
Valeri Fine

Back to top

javierggt

Joined: 03 Sep 2003
Posts: 19
Posted: Tue Aug 10, 2004 20:05 Post subject:


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).

that’s it… matter closed

Back to top

fine

Joined: 03 Sep 2003
Posts: 79
Location: BNL / Upton, USA
Posted: Tue Aug 10, 2004 21:21 Post subject:


javierggt wrote:

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 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.

javierggt wrote:

that’s it… matter closed

Agree Let’s move on



Hope this helps
Valeri Fine

Back to top

fine

Joined: 03 Sep 2003
Posts: 79
Location: BNL / Upton, USA
Posted: Tue Aug 10, 2004 21:25 Post subject:


Valeriy Onuchin wrote:

Hi,
I mentioned thread-safety just simply after
reading doc.trolltech.com/3.3/threads.html

Regards. Valeriy

Valerie, please read the up-to-date information

doc.trolltech.com/4.0/threads.html



Hope this helps
Valeri Fine

Back to top

Valeriy Onuchin

Joined: 27 Aug 2003
Posts: 300
Location: CERN,IHEP
Posted: Wed Aug 11, 2004 9:05 Post subject:


Thanks. I appologize. I’m silent.
No more Qt/QtRoot related messages

Regards. Valeriy

Back to top