RE: PyQt and PyROOT

From: Fine, Valeri <fine_at_bnl.gov>
Date: Thu, 11 Jan 2007 19:57:36 -0500


Hello Johan,
The information provided by Version511.news.html

> http://root.cern.ch/root/Version511.news.html
> The Qtcint interface:
> CINT has a new build option to generate the dictionary for the Qt
> classes. This dictionary is not built by default in the binary
> distribution files because the resulting library is quite large (>2
> Mbytes).

is correct. ( The size of the qtcint DLL under Windows is 1.5 Mgb and it is included into the QtRoot windows binary distribution from http://root.bnl.gov )

However, the README.txt below contains the information about qt-interface provided by CINT (by Masa Goto from Japan) rather by ROOT (since version 5.11)

> ----------------------------------------------------->
root/cint/lib/qt/README.txt
> This directory includes build environment for Qt library access DLL.
Run
> 'sh setup' to build 'include/qtcint.dll'. You need to modify
setup.bat
> script for setting Qt directory in your system. By default, c:\qt is
set.
> Basic Qt library can be used in an interpreted code by including
> <qtcint.dll>
> Platform support:
> Windows Visual C++ 6.0
> qtcint.dll hasn't been port to Linux/UNIX platforms. Your
> contribution will be highly appreciated.
> -----------------------------------------------------

  The up-to-date information about qtcint package provided by ROOT can be found http://root.cern.ch/root/doc/RootDoc.html "User's guide 5.14" "ROOT / Qt Integration Interfaces"
ftp://root.cern.ch/root/doc/chapter27.pdf section "Using Qt Class Library from the ROOT C++ Interpreter" page 514.

See the two examples under $ROOTSYS/tutorials:

      gui/QtFileDialog.C
and

      gui/QtMultiFileDialog.C

http://root.cern.ch/viewcvs/tutorials/gui/QtFileDialog.C?rev=1.1&content -type=text/vnd.viewcvs-markup  

#ifndef __CINT__
#  include <qfiledialog.h> 
#  include <qstring.h> 
#endif

TString QtFileDialog() {   

#ifdef __CINT__

  // Load the qt cint dictionary.
  // One is recommended to do that at once somewhere.
  // For example  from his/her custom rootlogon.C script
  gSystem->Load("$ROOTSYS/cint/include/qtcint"); #endif
  QString fileName = QFileDialog::getOpenFileName ();   return TString((const char *)fileName); }

This simple example must work on any platform. If it is not please file a bug report ASAP.

  Thank you.

              Valeri



Brookhaven National Laboratory
Upton, NY 11973, USA
Phone: +1 631 344 7806
Fax: +1 631 344 4206
E-mail: fine_at_bnl.gov

> -----Original Message-----
> From: Johan Bregeon [mailto:johan.bregeon_at_pi.infn.it]
> Sent: Thursday, January 11, 2007 2:22 PM
> To: Fine, Valeri
> Cc: Luca Baldini; ROOT Talk
> Subject: Re: PyQt and PyROOT
>
> Thanks Valeri for your comments :o)
> after some more investigation I am convinced the problem comes from
this
> line
> > Warning in <TClass::TClass>: no dictionary for class QWidget is
> available
> from python just doing 'from ROOT import TQtWidget' gives this
warning.
> looking into the TQtWidget source files, one can see that this classed
> is built on QWidget.
> so when trying to access this class with python, PyROOT tries to look
> for the QWidget class and does not find any information on it ('no
> dictionnary') because Qt is only a module of ROOT.
> The solution is as you say to build a dictionnary for the Qt classes,
> and that's exactly what 'qtcint' does...unfortunately this is only
> available under MS Windows now.
> So I guess we're stuck here unless we take the job of porting 'qtcint'
> under Linux.
>
> One hope would be to have PyROOT knowing about QWidget directly via
> PyQt, but I am not sure that's possible...
>
> Comments are still welcome :o)
> cheers,
> Johan Bregeon
>
> --------- some more information ---------
> http://root.cern.ch/root/Version511.news.html
> The Qtcint interface:
> CINT has a new build option to generate the dictionary for the Qt
> classes. This dictionary is not built by default in the binary
> distribution files because the resulting library is quite large (>2
> Mbytes).
>
> and
> root/cint/lib/qt/README.txt
> This directory includes build environment for Qt library access DLL.
Run
> 'sh setup' to build 'include/qtcint.dll'. You need to modify
setup.bat
> script for setting Qt directory in your system. By default, c:\qt is
set.
> Basic Qt library can be used in an interpreted code by including
> <qtcint.dll>
> Platform support:
> Windows Visual C++ 6.0
> qtcint.dll hasn't been port to Linux/UNIX platforms. Your
> contribution will be highly appreciated.
> -----------------------------------------------------
>
>
> Fine, Valeri wrote:
> > Hello Luca,
> >
> >
> >> Hi Valeri,
> >> I apologize for not writing on the root talk forum, but I just
> >> registered and it seems like
> >>
> >
> > I am forwarding your message to the ROOTTalk and RootDev lists
> >
> > I am not fluent with Python, sorry. Probably you (or some one from
the
> > roottalk) will need to explain me some basic things about Python and
> > Python ROOT.
> >
> > From the first glance your trouble is not caused by QtRoot class
like
> > TQtWidget rather by the "pure" Qt class which is QWidget.
> >
> > By this reason my first question is, "Does your code work if you
remove
> > the line
> >
> >
> >> self.Canvas = TQtWidget(self.CentralWidget)
> >>
> > and replace it with the "pure" Qt class like
> >
> > self.Canvas = QWidget(self.CentralWidget);
> > ?
> >
> > My guess it does work. I did pay an attention to the line
> >
> >
> >> self.CentralWidget = QWidget()
> >>
> >
> > that your python did not complain about.
> >
> > I did see the Python is aware about TQtWidget as well. However it
is
> > confused with the ctor parameter QWidget.
> > I do not know how one can "explain" python that this parameter is
very
> > pointer to the QWidget class the python is aware about via
> >
> >
> >> from qt import *
> >>
> >
> > I.e. I did see some confusion with the different dictionaries
however my
> > knowledge is not enough to pinpoint the reason.
> >
> > May be the only thing you need to do is to build the "qtcint"
RootCint
> > dictionary for the Qt classes
> > http://root.bnl.gov/QtRoot/htmldoc/src/qtclasses.h.html. However, I
am
> > not sure whether it makes sense for you. It may add the insult to
injury
> > ;)
> >
> > I hope some Python people on list can clarify the issue.
> >
> > Best Regards
> > Valeri Fine
> > ---------------
> > Brookhaven National Laboratory
> > Upton, NY 11973, USA
> > Phone: +1 631 344 7806
> > Fax: +1 631 344 4206
> > E-mail: fine_at_bnl.gov
> >
> >
> >> -----Original Message-----
> >> From: Luca Baldini [mailto:luca.baldini_at_pi.infn.it]
> >> Sent: Thursday, January 11, 2007 10:32 AM
> >> To: Fine, Valeri
> >> Cc: johan.bregeon_at_pi.infn.it
> >> Subject: PyQt and PyROOT
> >>
> >> Hi Valeri,
> >> I apologize for not writing on the root talk forum, but I just
> >> registered and it seems like
> >> it takes some time for my account to be activated.
> >> We are trying to put a ROOT canvas on a qt gui and we would like to
be
> >> able to do that from
> >> python with pyROOT and pyQt (ROOT 5.14.00, qt 3.3.3, pyQt 3.17,
python
> >> 2.5).
> >> Based on the c++ examples, we tried the following
> >>
> >> import sys
> >> from qt import *
> >> from ROOT import *
> >>
> >> class window(QMainWindow):
> >> def __init__(self):
> >> QMainWindow.__init__(self)
> >> self.CentralWidget = QWidget()
> >> self.setCentralWidget(self.CentralWidget)
> >> self.Layout = QGridLayout(self.CentralWidget)
> >> self.Canvas = TQtWidget(self.CentralWidget)
> >> self.Layout.addWidget(self.Canvas, 0, 0)
> >>
> >>
> >> if __name__ == '__main__':
> >> application = QApplication(sys.argv)
> >> w = window()
> >> w.show()
> >> application.exec_loop()
> >>
> >>
> >> but it doesn't work:
> >>
> >> Warning in <TClass::TClass>: no dictionary for class QWidget is
> >>
> > available
> >
> >> Traceback (most recent call last):
> >> File "window.py", line 18, in <module>
> >> w = window()
> >> File "window.py", line 12, in __init__
> >> self.Canvas = TQtWidget(self.CentralWidget)
> >> TypeError: TQtWidget::TQtWidget(QWidget* parent = 0) =>
> >> could not convert argument 1
> >>
> >>
> >> Any suggestion you can give me?
> >>
> >> Thanks a lot,
> >> Luca Baldini, INFN Pisa
> >>
Received on Fri Jan 12 2007 - 01:58:11 CET

This archive was generated by hypermail 2.2.0 : Fri Jan 12 2007 - 05:50:00 CET