RE: ruby with root + qt

From: Fine, Valeri <fine_at_bnl.gov>
Date: Mon, 27 Jul 2009 10:39:55 -0400


Hello Zoltan,  

> Hello Valeri,
> I tried to use the new version ROOT and qtRoot, but It dosn't work.
> I get the following error message:
> [pclhcb43] /scratch/zmathe/local > python qtexample.py
> Executable 'root.exe' was compiled with Qt 4.5.2, found Qt 4.4.2.
 

It seems to me the message above is clear.  

It says, that that you had compiled QtRoot using Qt 4.5.2 and you attempted to invoke ROOT against Qt 4.4.2.

> I used INSTALL_QTROOT.sh scripts from
> . . .
> http://root.bnl.gov/QtRoot/INSTALL_QTROOT.sh
 

Did you use it "as is " or had customized the script? If the later is correct I would like to see the "diff" file.  

The page http://root.bnl.gov/QtRoot/How2Install4Unix.html#x11short that describes the installation, says, " . . .
1. Set the package environment. To do that you need to find and select one of the 3 shell scripts created by the "Full Installation"

      source set_environment.csh
      source set_environment.sh  # this script is Ok for Cygwin environment as well)
      source set_environment.tcsh

. . . "
Did you perform that step ?  

> I recompiled the root. I used: ./configure
> --prefix=/scratch/zmathe/local/root --enable-python --enable-qt

Mmm , the step above is REDUNDANT, The http://root.bnl.gov/QtRoot/How2Install4Unix.html <http://root.bnl.gov/QtRoot/How2Install4Unix.html> suggests a few ways to use the script to compliment the existing ROOT installation made with no "--enable-qt" option.

Did you use the script "as is" or you customized it? I am wondering if you have built QtRoot twice and each time against of the different Qt version.

I really would like to see what you did "step -by-step" and I would like to see your environment variables for each of your step too.

Please make sure

  1. You have only version of Qt on your LD_LIBRARY_PATH
  2. There is ONLY one version of the libGQt.so shared library.

. . . .

> Can you help me? I have no idea what I am doing wrong.

I can not guess what you did wrong. Please tell me what you did "step-by-step". This way I'll be able to spot what you did wrong. ( may be you should send me a private message )

> Before I used ROOT 5.22, QtRoot and qt 4.4.2 and It is worked.

Does that Qt 4.4.2 is still installed on your computer? Do you have Qt 4.4.2 AND Qt 4.5.2 on your computer installed simultaneously? How did you separate the installations?

Valeri

Fine, Valeri wrote:
> Hello Robert,
>
> From your other post http://root.cern.ch/root/roottalk/roottalk09/0691.html

>

> I learned http://pastie.org/558537 your way to build ROOT:
>
> ./configure --prefix=/usr/local --enable-ruby --enable-python --enable-explicitlink --enable-gsl-shared --enable-rpath
>
> It indicates that you do not build the Qt-layer due lack of the optional "--enable-qt" build parameters.
> That means you should do that first.
> The recommended way is http://root.bnl.gov/QtRoot/How2Install4Unix.html#complement <http://root.bnl.gov/QtRoot/How2Install4Unix.html#complement>
> Hope this helps, Valeri
>
>

> ________________________________
>

> From: Riemann, Robert [mailto:robert.riemann_at_physik.hu-berlin.de]
> Sent: Thu 7/23/2009 2:34 PM
> To: Fine, Valeri
> Cc: roottalk_at_root.cern.ch; Zoltan.Mathe_at_ucdconnect.ie
> Subject: Re: [ROOT] ruby with root + qt
>
>
>

> I tested the new pyroot example, but the program aborted with the following
> message:
>
>

>
>> python qt3example.py
>>    

> Traceback (most recent call last):
> File "qt3example.py", line 47, in <module>
> terminator = ROOT.TQtRootSlot.CintSlot()
> File "lib/ROOT.py", line 345, in __getattr1
> return getattr( self, name )
> File "lib/ROOT.py", line 367, in __getattr2
> attr = _root.LookupRootEntity( name )
> AttributeError: TQtRootSlot
>

> I published qt3example.py on a code-snippet-wiki
> (editable without login):
> http://refactory.org/s/using_root_with_python_and_qt4/view/1
>

> Maybe I find some time on the weekend to read something about the qt-layer
> configs.
>

> Greets Robert
>
>

> Am Donnerstag, 23. Juli 2009 19:44:55 schrieb Fine, Valeri:
>
>> Hello Robert,
>>
>> I have neither Python nor PyQt installed to debug PyROOT related issue.
>>
>>    
>>> I tried to translate the python+qt example from the userguide to ruby.
>>>
>>>      
>>>> I had to add one modification (line 17, actually in comments) to get
>>>>        
>> it
>>
>>    
>>> working, but the program doesn't behave as well as the python-version.
>>>      
>> From the first glance the example:
>> ftp://root.cern.ch/root/doc/19PythonRuby.pdf  is for Qt3.
>>
>> That was fixed by Zoltan Mathe (See his E-mail below)
>>
>>    
>>>> -----Original Message-----
>>>> From: Zoltan MATHE [mailto:Zoltan.Mathe_at_ucdconnect.ie]
>>>> Sent: Wednesday, June 10, 2009 7:50 AM
>>>> To: Fine, Valeri
>>>> Cc: WLavrijsen_at_lbl.gov; Rene Brun
>>>> Subject: Re: [Fwd: root and qt problem]
>>>>
>>>> Hello, :)
>>>> I changed the qtexample.py, because it is implemented qt3. I attached
>>>>
>>>> the file. But it still dosn't work.
>>>>        
>>  ....
>>
>> I've submitted his patch to CERN.
>>
>> Index: qtexample.py
>> ===================================================================
>> --- qtexample.py        (revision 29535)
>> +++ qtexample.py        (working copy)
>> @@ -1,26 +1,29 @@
>>  import sys
>> -import qt
>>
>> +from PyQt4.QtGui import *
>> +from PyQt4.QtCore import *
>> +
>> +
>>  import ROOT
>>  import sip
>>
>> -class window(qt.QMainWindow):
>> +class window(QMainWindow):
>>     def __init__(self):
>>         # Init the main window.
>> -        qt.QMainWindow.__init__(self)
>> +        QMainWindow.__init__(self)
>>          self.resize(350, 350)
>>
>>       # Create the central widget.
>> -        self.CentralWidget = qt.QWidget(self)
>> +        self.CentralWidget = QWidget(self)
>>          self.setCentralWidget(self.CentralWidget)
>> -        self.Layout = qt.QGridLayout(self.CentralWidget)
>> +        self.Layout = QGridLayout(self.CentralWidget)
>>
>>      # Create a button.
>> -        self.QuitButton    = qt.QPushButton(self.centralWidget())
>> +        self.QuitButton    = QPushButton(self.centralWidget())
>>          self.QuitButton.setText('Quit')
>>          self.Layout.addWidget(self.QuitButton, 1, 0)
>>      # Connect the button.
>> -        qt.QObject.connect(self.QuitButton, qt.SIGNAL('clicked()'),
>> self.quit)
>> +        QObject.connect(self.QuitButton, SIGNAL('clicked()'),
>> self.quit)
>>
>>      # Create a root histogram.
>>          self.hist = ROOT.TH1F("pipo","pipo", 100, 0, 100)
>> @@ -31,7 +34,7 @@
>>
>>      # 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.Layout.addWidget(sip.wrapinstance(ROOT.AddressOf(self.Canvas)[0],QW
>> idget), 0, 0)
>>          self.hist.Draw()
>>
>>     def quit(self):
>> @@ -40,11 +43,12 @@
>>
>>
>>  if __name__ == '__main__':
>> -   application = qt.qApp
>> +   application = qApp
>>     terminator = ROOT.TQtRootSlot.CintSlot()
>> -   termAddress =
>> sip.wrapinstance(ROOT.AddressOf(terminator)[0],qt.QObject)
>> -   qt.QObject.connect(application,
>> qt.SIGNAL("lastWindowClosed()"),termAddress ,qt.SLOT("Terminate()"))
>> +   termAddress =
>> sip.wrapinstance(ROOT.AddressOf(terminator)[0],QObject)
>> +   QObject.connect(application,
>> SIGNAL("lastWindowClosed()"),termAddress ,SLOT("Terminate()"))
>>     w = window()
>>     w.show()
>>     ROOT.gApplication.Run(1)
>>     print 'Bye forever!'
>> +
>>
>>    
>>> Closing the TBrowser and restarting with another
>>> click on the button doesn't work.
>>> In some cases windows freeze. Without the
>>> fork-command the qt-window freezes.
>>>      
>>  From the first glance, your application lacks of the "event loop" by
>> some reason.
>>
>>    
>>> Maybe it's a bug. Does anyone have a better idea how to make it with
>>>      
>> ruby?
>>
>> I am not aware about any attempt to use QtRoot with ruby.
>>
>> Anyway,  before going further with the guess job please clarify:
>>
>>    1. What your ROOT version is
>>    2. What your Qt version is
>>    3. Does you activate QtROOT layer via  ROOT resource file
>>
>>       see: "Qt-layer Configuration"
>>            ftp://root.cern.ch/root/doc/26ROOTandQt.pdf
>>            p.424
>>        ?
>>     4. Does the patched version of "qtexample.py" works for you?
>>
>> Thank you, Valeri
>>
>>
>>
>>   -
>>
>>    
>>> Greets Robert
>>>
>>> Versions:
>>> Root v5.20/00
>>> Ruby ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]
>>> opensuse 11.1 with kde 4.2.4 and ruby-kde4 4.2.4
>>>
>>> Code with highlighting on pastie.org: http://pastie.org/548613
>>> Code without highlighting here:
>>>
>>> #!/usr/bin/env ruby
>>> $KCODE = 'u' # use utf8 encoding of this file
>>>
>>> require 'Qt4'
>>> require 'libRuby'
>>>
>>> class CustomWidget < Qt::PushButton
>>>
>>>   slots :browse
>>>
>>>   def initialize( label )
>>>     super( label )
>>>   end
>>>
>>>   def browse
>>>     tb = TBrowser.new
>>>     # fork do gApplication.Run end
>>>  end
>>>
>>> end
>>>
>>> a = Qt::Application.new(ARGV) # create an application object
>>> w = CustomWidget.new( 'Start TBrowser' ) # create an instance of our
>>>      
>> self-
>>
>>    
>>> made
>>> CustomWidget
>>> Qt::Object.connect( w, SIGNAL( :clicked ), w, SLOT( :browse ) )
>>> w.show # show our widget
>>> a.exec # run the application
>>>      
>
>
>

>
Received on Mon Jul 27 2009 - 16:40:02 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 27 2009 - 23:50:01 CEST