Qt 4.4.0, ROOT, and Mac Os X 10.5.3 Leopard

Hi,

I am trying to write a simple GUI to do event display using Qt. I am using the class TQtWidget to draw ROOT objects such as histograms and graphs onto the widgets. Everything compiles and works fine, but I notice some weird behavior when I do things such as click on the axis of a histogram, or right mouse-click onto the ROOT Canvas (loaded by TQtWidget). The behavior does not occur for any other Widget.

To be more specific, I get the following output, often repeating over and over, when I click on an axis of a histogram or graph:

Fri Jun 13 14:58:31 d-r19228.dhcp.fnal.gov ArgoQt[14444] : CGContextSaveGState: invalid context
Fri Jun 13 14:58:31 d-r19228.dhcp.fnal.gov ArgoQt[14444] : CGContextBeginPath: invalid context
Fri Jun 13 14:58:31 d-r19228.dhcp.fnal.gov ArgoQt[14444] : CGContextTranslateCTM: invalid context
Fri Jun 13 14:58:31 d-r19228.dhcp.fnal.gov ArgoQt[14444] : CGContextSetLineWidth: invalid context
Fri Jun 13 14:58:31 d-r19228.dhcp.fnal.gov ArgoQt[14444] : CGContextAddPath: invalid context
Fri Jun 13 14:58:31 d-r19228.dhcp.fnal.gov ArgoQt[14444] : CGContextDrawPath: invalid context
Fri Jun 13 14:58:31 d-r19228.dhcp.fnal.gov ArgoQt[14444] : CGContextRestoreGState: invalid context
Fri Jun 13 14:58:31 d-r19228.dhcp.fnal.gov ArgoQt[14444] : CGContextSetFillColorWithColor: invalid context

The following occurs when I right-mouse click on the Canvas:

Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextSetShouldAntialias: invalid context
Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextSetFontSize: invalid context
Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextGetTextMatrix: invalid context
Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextSetTextMatrix: invalid context
Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextSetTextDrawingMode: invalid context
Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextSetFont: invalid context
Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextSetTextPosition: invalid context
Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextShowGlyphsWithAdvances: invalid context
Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextSetTextMatrix: invalid context
Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextSetShouldAntialias: invalid context
Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextSetLineCap: invalid context
Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextSetLineWidth: invalid context
Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextSetLineJoin: invalid context
Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextSetLineDash: invalid context
Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextSetStrokeColorWithColor: invalid context
Fri Jun 13 15:03:09 d-r19228.dhcp.fnal.gov ArgoQt[14499] : CGContextSetFillColorWithColor: invalid context

Furthermore, when I right click on the canvas, a menu pops up but the buttons/options aren’t drawn properly (if at all).

I am a novice, so I am not sure what the problem seems to be, and I can’t seem to find a solution on the internet. Otherwise the program works great, but if this could be fixed, the ROOT objects in the widget would be much more useful.

My version is ROOT 5.19/05 (trunk@24224). I am using Qt 4.4.0. My OS is Mac OS X Leopard 10.5.3

Thanks,
Taritree

Alas I have no Mac to reproduce your problem.
Therefore, I would appreciate you apply INSTALL_QTROOT.sh script to re-build your installation (By default it uses ROOT 5.18) and tell me whether the problem still persists. See some extra information about the script in question
root.cern.ch/phpBB2/viewtopic.php?t=6753

Hi Dr. Fine,

Thank you for your reply and the script. I tried it, and it made it through. I believe Qt-4.4.0 installed correctly. Both root and QtRoot compiled it seems. However, when I run root, I get the following error when I ask it to draw a canvas:
root [0] c = new TCanvas()
Error in TUnixSystem::DynamicPathName: GQt[.so | .sl | .dl | .a | .dll] does not exist in .:/Users/twongjirad/software/rootsvn/rootfine/root/lib::/Users/twongjirad/software/rootsvn/rootfine/root/lib:/Users/twongjirad/software/rootsvn/rootfine/root/lib:/Users/twongjirad/software/rootsvn/rootfine/Qt-4.4.0/lib:/Users/twongjirad/software/rootsvn/rootfine/root:
Warning in TCanvas::ResizePad: c1 width changed from 0 to 10

(class TCanvas*)0x182ca00

As a reference, here are what I guess are my relevant environment variables:

QTDIR=/Users/twongjirad/software/rootsvn/rootfine/Qt-4.4.0
QTROOTSYSDIR=/Users/twongjirad/software/rootsvn/rootfine/root
PATH=/sw/bin:/sw/sbin:/Users/twongjirad/software/rootsvn/rootfine/root/bin:/Users/twongjirad/software/rootsvn/rootfine/Qt-4.4.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin:/Users/twongjirad/software/wired/bin:/usr/X11R6/bin
QT_CONF_OPTS=-no-framework
QMAKESPEC=macx-g++
ROOTSYS=/Users/twongjirad/software/rootsvn/rootfine/root
DYLD_LIBRARY_PATH=/Users/twongjirad/software/rootsvn/rootfine/root/lib:/Users/twongjirad/software/rootsvn/rootfine/Qt-4.4.0/lib:/Users/twongjirad/software/rootsvn/rootfine/root

I noticed that in the script, some folders which I assumed contain an older version of qtRoot are renamed to qtRoot.root. I didn’t find those in the resulting root folder. Not sure if that is a sign of what might be causing the problem.

Also, at the end of the script, an attempt to test an example didn’t work:
Project MESSAGE: Found Qt extensions library !!!
Project MESSAGE:
Project MESSAGE: WARNING: The was not found !!!
Project MESSAGE: Please update your Qt layer version from root.bnl.gov
Project MESSAGE:

And finally, I tried changing the environment variables that were set in the environment.plist to include under DYLD_LIBRARY_PATH = /Users/twongjirad/software/rootsvn/rootfine/qtRoot

opening up a canvas gives a slightly different error.

root [0] c = new TCanvas()
** $Id: TGQt.cxx,v 1.179 2008/05/19 14:26:30 fine Exp $ this=0x29b9120
Error in TUnixSystem::DynamicPathName: QtRootGui[.so | .sl | .dl | .a | .dll] does not exist in $(ROOTSYS)/cint/include:.:/Users/twongjirad/software/rootsvn/rootfine/root/lib::/Users/twongjirad/software/rootsvn/rootfine/root/lib:/Users/twongjirad/software/rootsvn/rootfine/root/lib:/Users/twongjirad/software/rootsvn/rootfine/Qt-4.4.0/lib:/Users/twongjirad/software/rootsvn/rootfine/root:/Users/twongjirad/software/rootsvn/rootfine/qtRoot:
(class TCanvas*)0x182ca00
Error in TGQt::TGQt::CopyPixmap: Wrong TGuiFactory implementation was provided. Please, check your plugin settings
src/TGQt.cxx:1252: failed assertion `dst != (QPaintDevice *)-1’

I hope the information here is useful, as I am not too sure what to try. Thanks so much for your help,
Taritree

Oops. I realized that the copy commands are for windows only, so please ignore those comments, though I am sure that is not my only misunderstanding.

Hi Dr. Fine,

I apologize for making so many posts.

So I investigated further at it seems that when root configures the build, it missed the installation of Qt and does not enable it to be built with root. I think I fixed it by adding --with-qt-incdir=[QTDIR] and --with-qt-libdir=[QTDIR]

I check the list of enabled features, and qt is one of them.

I am then able to compile root. However, once it runs it crashes with this error:

root [0] c = new TCanvas()
** $Id: TGQt.cxx 20882 2007-11-19 11:31:26Z rdm $ this=0x25a6430
Error in TUnixSystem::DynamicPathName: QtRootGui[.so | .sl | .dl | .a | .dll] does not exist in $(ROOTSYS)/cint/include:.:/Users/twongjirad/software/rootsvn/rootfine/root/lib::/Users/twongjirad/software/rootsvn/rootfine/root/lib:/Users/twongjirad/software/rootsvn/rootfine/root/lib:/Users/twongjirad/software/qt-mac-4.4.0/lib:/Users/twongjirad/software/rootsvn/rootfine/root:/Users/twongjirad/software/rootsvn/rootfine/root:
(class TCanvas*)0x182ce00

*** Break *** bus error
/Users/twongjirad/67839: No such file or directory.
Attaching to process 67839.
Reading symbols for shared libraries . done
Reading symbols for shared libraries … done
0x91a814b5 in wait4 ()

========== STACKS OF ALL THREADS ==========

Thread 1 (process 67839 thread 0x20b):
#0 0x91a814b5 in wait4 ()
#1 0x91a7f007 in system$UNIX2003 ()
#2 0x0098e515 in TUnixSystem::Exec (this=0x17037b0, shellcmd=0x1867a10 “/usr/bin/gdb -batch -n -x /Users/twongjirad/software/rootsvn/rootfine/root/etc/gdb-backtrace-script -p 67839 > /tmp/rootstack.67839 2>&1”) at unix/src/TUnixSystem.cxx:1879
#3 0x0098e8a7 in TUnixSystem::StackTrace (this=0x17037b0) at unix/src/TUnixSystem.cxx:1970
#4 0x009915d1 in TUnixSystem::DispatchSignals (this=0x17037b0, sig=kSigBus) at unix/src/TUnixSystem.cxx:1027
#5 0x00991702 in SigHandler (sig=kSigBus) at unix/src/TUnixSystem.cxx:351
#6 0x00990654 in sighandler (sig=10) at unix/src/TUnixSystem.cxx:3290
#7
#8 0x036b5edb in QPaintDevice::paintingActive (this=0xffffffff) at qpaintdevice.h:169
#9 0x036b287e in TGQt::CopyPixmap (this=0x25a6430, wid=2, xpos=0, ypos=0) at qt/src/TGQt.cxx:1188
#10 0x02e61011 in TPad::CopyPixmap (this=0x182ce00) at gpad/src/TPad.cxx:888
#11 0x02e464d1 in TCanvas::CopyPixmaps (this=0x182ce00) at gpad/src/TCanvas.cxx:700
#12 0x02e47374 in TCanvas::Flush (this=0x182ce00) at gpad/src/TCanvas.cxx:965
#13 0x02e4b583 in TCanvas::Update (this=0x182ce00) at gpad/src/TCanvas.cxx:2010
#14 0x0095f1b9 in TCint::UpdateAllCanvases () at meta/src/TCint.cxx:1539
#15 0x0095f3ba in TCint::ProcessLine (this=0x170a680, line=0xd3fddb “TRint::EndOfLineAction();”, error=0x0) at meta/src/TCint.cxx:294
#16 0x0095f829 in TCint::ProcessLineSynch (this=0x170a680, line=0xd3fddb “TRint::EndOfLineAction();”, error=0x0) at meta/src/TCint.cxx:365
#17 0x0095ec13 in TCint::EndOfLineAction (this=0x170a680) at meta/src/TCint.cxx:183
#18 0x000378e6 in TRint::HandleTermInput (this=0x177b110) at rint/src/TRint.cxx:534
#19 0x00035d7f in TTermInputHandler::Notify (this=0x20dc020) at rint/src/TRint.cxx:123
#20 0x00038a1c in TTermInputHandler::ReadNotify (this=0x20dc020) at rint/src/TRint.cxx:115
#21 0x0098cdc9 in TUnixSystem::CheckDescriptors (this=0x17037b0) at unix/src/TUnixSystem.cxx:1129
#22 0x0099184d in TUnixSystem::DispatchOneEvent (this=0x17037b0, pendingOnly=false) at unix/src/TUnixSystem.cxx:836
#23 0x0091e0b5 in TSystem::InnerLoop (this=0x17037b0) at base/src/TSystem.cxx:392
#24 0x0091de3c in TSystem::Run (this=0x17037b0) at base/src/TSystem.cxx:342
#25 0x008c12d7 in TApplication::Run (this=0x177b110, retrn=false) at base/src/TApplication.cxx:940
#26 0x000368fe in TRint::Run (this=0x177b110, retrn=false) at rint/src/TRint.cxx:385
#27 0x00001b08 in main (argc=1, argv=0xbffff20c) at main/src/rmain.cxx:29

my environment variables when I run ROOT are:

ANPATH=/sw/share/man:/usr/share/man:/usr/local/share/man:/usr/local/man:/Library/TeX/Distributions/.DefaultTeX/Contents/Man:/usr/X11/man:/sw/lib/perl5/5.8.8/man:/usr/X11R6/man
TERM_PROGRAM=Apple_Terminal
TERM=xterm-color
SHELL=/bin/bash
TMPDIR=/var/folders/Xw/XwCTiyI9HSKnZR8Adx8sCU+++TI/-Tmp-/
PERL5LIB=/sw/lib/perl5:/sw/lib/perl5/darwin
Apple_PubSub_Socket_Render=/tmp/launch-6QjlRJ/Render
TERM_PROGRAM_VERSION=240
QTDIR=/Users/twongjirad/software/qt-mac-4.4.0
QTROOTSYSDIR=/Users/twongjirad/software/rootsvn/rootfine/root
SGML_CATALOG_FILES=/sw/etc/sgml/catalog
USER=twongjirad
COMMAND_MODE=unix2003
__CF_USER_TEXT_ENCODING=0x1F5:0:0
PATH=/sw/bin:/sw/sbin:/Users/twongjirad/software/rootsvn/rootfine/root/bin:/Users/twongjirad/software/qt-mac-4.4.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin:/Users/twongjirad/software/wired/bin:/usr/X11R6/bin
XML_CATALOG_FILES=/sw/etc/xml/catalog
PWD=/Users/twongjirad
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
LANG=en_US.UTF-8
ROOTSYS=/Users/twongjirad/software/rootsvn/rootfine/root
SHLVL=1
HOME=/Users/twongjirad
DYLD_LIBRARY_PATH=/Users/twongjirad/software/rootsvn/rootfine/root/lib:/Users/twongjirad/software/qt-mac-4.4.0/lib:/Users/twongjirad/software/rootsvn/rootfine/root:/Users/twongjirad/software/rootsvn/rootfine/root
LOGNAME=twongjirad
INFOPATH=/sw/share/info:/sw/info:/usr/share/info
DISPLAY=/tmp/launch-ZzzLB3/:0
SECURITYSESSIONID=710f70
_=/usr/bin/env

Thank you again,
Taritree

[quote=“twongjirad”]…
I tried it, and it made it through.[/quote]Ok :smiley:

[quote=“twongjirad”]I believe Qt-4.4.0 installed correctly. Both root and QtRoot compiled it seems.[/quote]Can you print the list of the shared libraries the QtRoot compilation produced? [quote=“twongjirad”]However, when I run root, I get the following error when I ask it to draw a canvas:
root [0] c = new TCanvas()
Error in TUnixSystem::DynamicPathName: GQt[.so | .sl | .dl | .a | .dll] does not exist
…[/quote] The script has to generate a bunch of the other scripts (one per each “shell” brand like bash, csh, tcsh, Win32 cmd etc) to set the env variable properly. Did you see those scripts, did you apply the correct one ? Since the script is not a part the ROOT distribution, please, forward all your QtRoot related questions to lists.bnl.gov/mailman/listinfo/qt-root-l The script authors listen that list and will be able to assist you. I believe they use it to install QtRoot on thier Mac machines successfully.

[quote=“twongjirad”]…
So I investigated further at it seems that when root configures the build, it missed the installation of Qt and does not enable it to be built with root[/quote] No, it does not miss anything like that. It is to install QtRoot with a separate dedicated step. [quote=“twongjirad”]I think I fixed it by adding --with-qt-incdir=[QTDIR] and --with-qt-libdir=[QTDIR]
I check the list of enabled features, and qt is one of them
[/quote]I appreciate your effort. However, I am sorry, what you did is NOT correct. It added the “insult to injury”. You should apply the script “as is” and set the environment variables using the “set_env.xxx” script to set the environment suitable for your shell/OS combination.
The last script statements are

## mac-specific warnings echo " MAC-OSX: you should now create a folder in your home named .MacOSX" echo " and copy there the file environment.plist" echo "" fi echo "====================== BYE BYE! ======================" echo ""Did you see it?