Index: trunk/geant4/config/G4UI_USE.gmk
===================================================================
--- trunk/geant4/config/G4UI_USE.gmk	(revision 764)
+++ trunk/geant4/config/G4UI_USE.gmk	(revision 766)
@@ -65,4 +65,7 @@
   LOAD_QT   = 1
   CPPFLAGS += -DG4UI_USE_QT
+  INTYLIBS += -DG4UI_USE_QT
+else
+  INTYLIBS += -DNO_G4VIS_USE_OIQT
 endif
 
Index: trunk/geant4/config/G4VIS_USE.gmk
===================================================================
--- trunk/geant4/config/G4VIS_USE.gmk	(revision 764)
+++ trunk/geant4/config/G4VIS_USE.gmk	(revision 766)
@@ -62,4 +62,8 @@
   VISLIBS += -lG4OpenGL_moc
   INC_QT   = 1
+  LOAD_GLQT   = 1
+  INTYLIBS += -DG4VIS_USE_OIQT
+else
+  INTYLIBS += -DNO_G4VIS_USE_OIQT
 endif
 ifdef G4VIS_USE_OPENGLWIN32
@@ -87,5 +91,5 @@
   CPPFLAGS += -DG4VIS_USE_OIQT
   INC_QT   = 1
-  LOAD_QT   = 1
+  LOAD_GLQT   = 1
 endif
 ifdef G4VIS_USE_OIWIN32
Index: trunk/geant4/config/common.gmk
===================================================================
--- trunk/geant4/config/common.gmk	(revision 764)
+++ trunk/geant4/config/common.gmk	(revision 766)
@@ -5,4 +5,5 @@
 # Libraries are created according to G4SYSTEM. G.Cosmo, 11/6/96.
 # Introduced G4LIBDIR and G4TMPDIR. G.Cosmo, 23/6/98.
+# Introduced Qt moc rule, L.Garnier 15/2/08.
 
 ifndef G4LIBDIR
@@ -14,5 +15,7 @@
 
 ifneq ($(G4INTY_BUILD_QT),)
-  sources += $(moc_sources)
+  moc_inc = $(shell grep -l "Q_OBJECT" include/*.hh )
+  moc_files := $(patsubst include/%.hh, src/%_moc.cc, $(moc_inc))
+  sources += $(moc_files)
 endif
 
@@ -65,4 +68,25 @@
 endif
 
+###############################################################################
+#
+# Actual moc files for Qt files
+#
+# moc sources and headers: used for Qt signal/slot 
+# - all headers which use signals/slots have the macro "Q_OBJECT" present
+#   in the class definitions; these all need to be processed by the
+#   "meta object compiler (moc)" which generates extra source code to
+#   implement the signal/slots, i.e., if "foo.h" contains the token "Q_OBJECT"
+#   it will be used by moc to generate the file "foo_moc.cpp" (the _moc. is
+#   just an arbitrary extension to make it easier to identify sources
+#   generated by moc).
+
+ifneq ($(G4INTY_BUILD_QT),)
+src/%_moc.cc: include/%.hh
+	@echo Making moc file for $< ...
+	@if [ `$(QTHOME)/bin/moc -v 2>&1 | grep "Qt 3" | wc -l ` -gt 0 ]; then \
+	$(QTMOC) -o $@ $<;\
+	else $(QTMOC) $(MOC_MACRO) -o $@ $<; \
+	fi;
+endif
 
 ###############################################################################
@@ -81,5 +105,5 @@
 # .PHONY targets are executed regardless of time-stamp of any file of
 # same name.
-.PHONY: all obj lib clean clean_libs includes
+.PHONY: all moc_inc obj lib clean clean_libs includes
 
 obj: $(G4TMPDIR)/obj.last
Index: trunk/geant4/config/interactivity.gmk
===================================================================
--- trunk/geant4/config/interactivity.gmk	(revision 764)
+++ trunk/geant4/config/interactivity.gmk	(revision 766)
@@ -33,4 +33,10 @@
 endif
 
+########################### Open GL Qt ###############################
+# Should be before X11.
+ifdef LOAD_GLQT
+  INTYLIBS += $(GLQTLIBS)
+endif
+
 ########################### OpenGL ###############################
 
@@ -39,5 +45,7 @@
 endif
 ifdef LOAD_GL
-  INTYLIBS += $(OGLLIBS)
+  INTYLIBS += -D_LOAD_GL $(OGLLIBS) -D_LOAD_GL
+else
+  INTYLIBS += -D_NO_LOAD_GL
 endif
 
Index: trunk/geant4/config/moc.gmk
===================================================================
--- trunk/geant4/config/moc.gmk	(revision 764)
+++ trunk/geant4/config/moc.gmk	(revision 766)
@@ -5,5 +5,5 @@
 # Libraries are created according to G4SYSTEM. G.Cosmo, 11/6/96.
 # Introduced G4LIBDIR and G4TMPDIR. G.Cosmo, 23/6/98.
-# Introduced Qt moc rule, L.Garnier 15/2/08.
+# Introduced Qt moc rule, L.Garnier 16/2/08.
 
 ifndef G4LIBDIR
@@ -13,12 +13,13 @@
 
 ifneq ($(G4INTY_BUILD_QT),)
-#  dirMoc := OpenGL
-  moc_dir_name := $(patsubst G4%_moc, ../%, $(name))
-  moc_inc := $(shell grep -l "Q_OBJECT" ../$(dirMoc)/include/*.hh)
+  moc_inc := $(shell (grep -l "Q_OBJECT" ../$(dirMoc)/include/*.hh))
+  moc_tst := $(shell ls -al testMoc.gmk)
   moc_sources := $(patsubst ../$(dirMoc)/include/%.hh, src/%_moc.cc, $(moc_inc))
 
-#  moc_inc := $(shell grep -l "Q_OBJECT" $(moc_dir_name)/include/*.hh)
+#  moc_dir_name := $(patsubst G4%_moc, %, $(name))
+#  moc_tst := $(shell ls -al ../$(moc_dir_name) >/Users/garnier/tst)
+#  moc_inc := $(shell (grep -l "Q_OBJECT" ../$(moc_dir_name)/include/*.hh))
 #  moc_tst := $(shell ls -al $(moc_inc) >/Users/garnier/tst)
-#  moc_sources := $(patsubst $(moc_dir_name)/include/%.hh, src/%_moc.cc, $(moc_inc))
+#  moc_sources := $(patsubst ../$(moc_dir_name)/include/%.hh, src/%_moc.cc, $(moc_inc))
 endif
 
@@ -39,5 +40,5 @@
 
 ifneq ($(G4INTY_BUILD_QT),)
-src/%_moc.cc: include/%.hh
+src/%_moc.cc: ../$(dirMoc)/include/%.hh
 	@echo Making moc file for $< ...
 	@if [ `$(QTHOME)/bin/moc -v 2>&1 | grep "Qt 3" | wc -l ` -gt 0 ]; then \
@@ -46,5 +47,5 @@
 	fi;
 
-src/%.cc: src/%_moc.cc
+src/%.cc:
 	@echo Making toto $< ...
 	@if [ ! -d $(G4TMPDIR) ] ; then mkdir -p $(G4TMPDIR)  ;fi
Index: trunk/geant4/config/sys/Darwin-g++.gmk
===================================================================
--- trunk/geant4/config/sys/Darwin-g++.gmk	(revision 764)
+++ trunk/geant4/config/sys/Darwin-g++.gmk	(revision 766)
@@ -80,6 +80,13 @@
     QT3LIBS    := -L$(QTHOME)/lib -lqt -lqui
     QT4LIBS    := -F$(QTHOME)/lib -framework QtCore -framework QtGui
+    QT4LIBS    += -framework -framework QtSql -framework QtXml
+    QTLIBS     := $(shell test -f $(QTHOME)/Qt3Support.framework/Qt3Support && echo $(QT4LIBS) || echo $(QT3LIBS))
+  endif
+
+  ifndef GLQTLIBS
+    QT3LIBS    := -L$(QTHOME)/lib -lqt -lqui
+    QT4LIBS    := -F$(QTHOME) -framework QtCore -framework QtGui
     QT4LIBS    += -framework QtOpenGL -framework QtSql -framework QtXml
-    QTLIBS     := $(shell test -f $(QTHOME)/lib/Qt3Support.framework/Qt3Support && echo $(QT4LIBS) || echo $(QT3LIBS))
+    QTLIBS     := $(shell test -f $(QTHOME)/Qt3Support.framework/Qt3Support && echo $(QT4LIBS) || echo $(QT3LIBS))
   endif
 
@@ -87,4 +94,5 @@
     @libdir=`(cd $(@D);/bin/pwd)`; \
      cd $(G4TMPDIR); \
+     echo $(INTYLIBS); \
      g++ -dynamiclib -single_module -undefined dynamic_lookup \
          -o $$libdir/$(@F) $(INTYLIBS) *.o
