Hello Johan,
Your script did not work because you did not use Qt properly. (That has nothing to do with ROOT /QtRoot) Please, follow my previous message those advices are still valid and . . . To fix
> there was no canvas in the main window,
> meaning we still have a problem with the layout."
you have to replace your
> self.CentralWidget = qt.QWidget()
with
self.CentralWidget = qt.QWidget(self)
To fix
> but the application was hanging up somewhere
you have to remove your second event loop:
> application.exec_loop()
Hope this helps, Valeri
I am begging a pardon with some delay . . . you see your script is the first Python script I am dealing with ;) and I still have to install PyQt to try it myself.
PS. Please find the working equivalent of your Python script in C++ ( I did test on lxplus, it does work) #include <TRint.h>
#include <qmainwindow.h>
#include <qlayout.h>
#include <TH1.h>
#include <TQtWidget.h>
QMainWindow *window()
{
// Create the main window
QMainWindow *self = new QMainWindow();
// Create the central widget.
QWidget *CentralWidget = new QWidget(self); // This was wrong !!!
self->setCentralWidget(CentralWidget);
QGridLayout *Layout = new QGridLayout(CentralWidget);
// Create a root histogram
TH1F *hist = new TH1F("pipo","pipo", 100, 0, 100);
// Create the main TQtWidget (using sip to get the pointer to the central widget).
TQtWidget *Canvas = new TQtWidget(CentralWidget);
// Place the TQtWidget in the main grid layout and draw the histogram.
Layout->addWidget(Canvas,0,0);
hist->Draw();
return self;
}
int main( int argc, char **argv )
{
// Create an interactive ROOT application
// This portion is to be done by PyROOT for you
TRint *theApp = new TRint("Rint", &argc, argv); // This portion is to be done by PyROOT for you
// Create Qt object within ROOT application
QMainWindow *w = window();
w->resize(350,350);
w->show();
// and enter the ROOT event loop...
// This portion is to be done by PyROOT for you
theApp->Run(); // This portion is to be done by PyROOT for you
printf(" Goob bye ROOT !\n");
}
From: Johan Bregeon [mailto:johan.bregeon_at_pi.infn.it]
Sent: Mon 1/15/2007 12:41 PM
To: WLavrijsen_at_lbl.gov
Cc: Fine, Valeri; Luca Baldini; ROOT Talk
Subject: Re: [ROOT] RE: PyQt and PyROOT
Thanks all for your help,
we were able to solve a couple of more problems following your advice,
but unfortunately we couldn't have something stable working.
but we actually do not have the time / man power /knowledge to go
further with building up a ROOT application with a Qt gui, using pyroot
and pyqt, so we decided to stop here on that point.
Our new idea is to use only pyRoot for this purpose, so let me start
another trade...
cheers,
Johan
WLavrijsen_at_lbl.gov wrote:
> Dear all,
>
>> 2) What is creating the 'other' QApplication ? (we instance only one in >> the main !) >> >
>
>> ROOT had been started (QApplication was created too via ROOT Qt >> plug-in). May be, Wim can explain us at which point the PyROOT >> instantiates ROOT. >> >
>
>
>
>>
> "Stop making excuses for your software." --first step towards quality
> "GIGO is not a valid design pattern." --corollary
This archive was generated by hypermail 2.2.0 : Tue Jan 16 2007 - 17:50:01 CET