Re: RE: PyQt and PyROOT

From: Johan Bregeon <johan.bregeon_at_pi.infn.it>
Date: Fri, 12 Jan 2007 16:25:08 +0100


Hello all,
Thanks to your comments, we were able to make a step forward. We actually had to use both 'qtcint' and sip to have something working. Here is the piece of code :



import sys
import qt
import ROOT
import sip
ROOT.gSystem.Load('qtcint')

class window(qt.QMainWindow):

   def __init__(self):

       # Init the main window.
        qt.QMainWindow.__init__(self)

    self.resize(350, 350)    

# Create the central widget.

        self.CentralWidget = qt.QWidget()
        self.setCentralWidget(self.CentralWidget)
        self.Layout = qt.QGridLayout(self.CentralWidget)
   

# Create a root histogram.

    self.hist = ROOT.TH1F("pipo","pipo", 100, 0, 100)    

# Create the main TQtWidget (using sip to get the pointer to the
central widget).

    self.Address = sip.unwrapinstance(self.CentralWidget)
    self.Canvas = ROOT.TQtWidget(sip.voidptr(self.Address).ascobject())
    self.Canvas.resize(300, 300)
   

# Place the TQtWidget in the main grid layout and draw the histogram.

self.Layout.addWidget(sip.wrapinstance(ROOT.AddressOf(self.Canvas)[0], qt.QWidget), 0, 0)

    self.Canvas.show()
    self.Canvas.cd()
    self.hist.Draw()
    self.Canvas.Refresh()
   

if __name__ == '__main__':

   application = qt.QApplication(sys.argv)    qt.QObject.connect(application, qt.SIGNAL("lastWindowClosed()"), application, qt.SLOT("quit()"))

   w = window()
   w.show()
   application.exec_loop()


It's almost doing what we want to...meaning, that it's running but ultimately the Histogram does not show up on the GUI. Notes :
  + If we add the histogram directly to the 'MainWindow' it's working, but we obviously need the 'layout' step to work.

We also have these warnings :
$ python pyqtroot.py
** $Id: TGQt.cxx,v 1.35 2006/12/12 20:12:47 brun Exp $ this=0x9fc8d90 Error in <TUnixSystem::DynamicPathName>: QtGui[.so | .sl | .dl | .a | .dll] does not exist in
$(ROOTSYS)/cint/include:.:/usr/local/root/v5.14.00/lib:/usr/local/root/v5.14.00/lib:/usr/local/python2.5/lib:/usr/local/lib QApplication: There should be max one application object Warning in <TClass::TClass>: no dictionary for class Qt is available Warning in <TClass::TClass>: no dictionary for class QPaintDevice is available

  1. Where does this QtGui library comes from ? (there seems to be one in qt4 but we do not have any in qt3)
  2. What is creating the 'other' QApplication ? (we instance only one in the main !)
  3. We're now loading the 'qtcint' dictionnary, so why some Qt class dictionaries are still missing ?

Thanks for comments,
cheers
Johan Received on Fri Jan 12 2007 - 16:25:20 CET

This archive was generated by hypermail 2.2.0 : Tue Jan 16 2007 - 05:50:00 CET