Index: trunk/source/interfaces/basic/include/G4UIQt.hh
===================================================================
--- trunk/source/interfaces/basic/include/G4UIQt.hh	(revision 1158)
+++ trunk/source/interfaces/basic/include/G4UIQt.hh	(revision 1163)
@@ -157,5 +157,6 @@
   QWidget *visWidget;
   QTabWidget* fTabWidget;
- 
+  QString fCoutText;
+
 signals : 
   void myClicked(const QString &text);
@@ -171,4 +172,5 @@
   void CommandHistoryCallback();
   void lookForHelpStringCallback();
+  void UpdateTabWidget(int);
 };
 
Index: trunk/source/interfaces/basic/src/G4UIQt.cc
===================================================================
--- trunk/source/interfaces/basic/src/G4UIQt.cc	(revision 1158)
+++ trunk/source/interfaces/basic/src/G4UIQt.cc	(revision 1163)
@@ -104,6 +104,7 @@
 ,char** argv
 )
-  :fHelpDialog(NULL),
- fTabWidget(NULL)
+:fHelpDialog(NULL)
+,fTabWidget(NULL)
+,fCoutText("Output")
 {
   G4Qt* interactorManager = G4Qt::getInstance (argc,argv,(char*)"Qt");
@@ -162,10 +163,8 @@
   QWidget *mainWidget = new QWidget(fMainWindow);
 #if QT_VERSION < 0x040000
-  QSplitter *visCoutSplitter = new QSplitter(Qt::Vertical,fMainWindow);
-  QSplitter *coutHistorySplitter = new QSplitter(Qt::Vertical,fMainWindow);
+  QSplitter *visHistorySplitter = new QSplitter(Qt::Vertical,fMainWindow);
   QSplitter *historyCommandLineSplitter = new QSplitter(Qt::Vertical,fMainWindow);
 #else
-  QSplitter *visCoutSplitter = new QSplitter(Qt::Vertical,mainWidget);
-  QSplitter *coutHistorySplitter = new QSplitter(Qt::Vertical,mainWidget);
+  QSplitter *visHistorySplitter = new QSplitter(Qt::Vertical,mainWidget);
   QSplitter *historyCommandLineSplitter = new QSplitter(Qt::Vertical,mainWidget);
 #endif
@@ -176,6 +175,9 @@
   // Set layouts
 
-  visWidget = new QWidget(visCoutSplitter);
-  QWidget* coutWidget = new QWidget(coutHistorySplitter);
+  fTabWidget = new QTabWidget;
+  connect(fTabWidget, SIGNAL(currentChanged ( int ) ), SLOT(UpdateTabWidget(int)));
+
+  visWidget = new QWidget(visHistorySplitter);
+  QWidget* coutWidget = new QWidget(fTabWidget);
   QWidget* historyWidget = new QWidget(historyCommandLineSplitter);
   QWidget* commandLineWidget = new QWidget(historyCommandLineSplitter);
@@ -188,4 +190,6 @@
   // fill them
 
+  fTabWidget->addTab(coutWidget,fCoutText);
+ 
   fTextArea = new QTextEdit(coutWidget);
   QPushButton *clearButton = new QPushButton("clear",coutWidget);
@@ -252,13 +256,9 @@
   historyCommandLineSplitter->addWidget(commandLineWidget);
 
-  // The splitter for Cout/History
-  coutHistorySplitter->addWidget(coutWidget);
-  coutHistorySplitter->addWidget(historyCommandLineSplitter);
-
   // The splitter for Vis/Cout
-  visCoutSplitter->addWidget(visWidget);
-  visCoutSplitter->addWidget(coutHistorySplitter);
-
-  mainLayout->addWidget(visCoutSplitter);
+  visHistorySplitter->addWidget(visWidget);
+  visHistorySplitter->addWidget(historyCommandLineSplitter);
+
+  mainLayout->addWidget(visHistorySplitter);
 
 #endif
@@ -270,5 +270,5 @@
   fMainWindow->setCentralWidget(mainWidget);
 #else
-  fMainWindow->setCentralWidget(visCoutSplitter);
+  fMainWindow->setCentralWidget(visHistorySplitter);
 #endif
 
@@ -348,21 +348,38 @@
 )
 {
-  if (fTabWidget == NULL) {
-    fTabWidget = new QTabWidget;
-  }
-  if (!aWidget) return;
-
-#if QT_VERSION < 0x040000
-  aWidget->reparent(visWidget,0,QPoint(0,0));  
-#else
-  aWidget->setParent(visWidget);
-#endif
-
-  fTabWidget->addTab(aWidget,name);
-  QHBoxLayout *mainLayout = new QHBoxLayout(visWidget);
-  mainLayout->setMargin(0);
-  mainLayout->setSpacing(0);   
-  mainLayout->addWidget(fTabWidget);
-}
+  if (fTabWidget != NULL) {
+    if (!aWidget) return;
+    
+#if QT_VERSION < 0x040000
+    aWidget->reparent(visWidget,0,QPoint(0,0));  
+#else
+    aWidget->setParent(visWidget);
+#endif
+    
+    fTabWidget->addTab(aWidget,name);
+    QHBoxLayout *mainLayout = new QHBoxLayout(visWidget);
+    mainLayout->setMargin(0);
+    mainLayout->setSpacing(0);   
+    mainLayout->addWidget(fTabWidget);
+  }
+}
+
+
+void G4UIQt::UpdateTabWidget(int tabNumber) {
+  QString text = fTabWidget->tabText (tabNumber); 
+  if ( text != fCoutText) {
+
+    // Then we have to do /vis/viewer/select on the selelected tab
+    QString paramSelect = QString("/vis/viewer/select ")+text;
+    QString paramFlush = QString("/vis/viewer/flush ")+text;
+    G4UImanager* UI = G4UImanager::GetUIpointer();
+    if(UI!=NULL)  {
+      UI->ApplyCommand(paramSelect.toStdString().c_str());
+      UI->ApplyCommand(paramFlush.toStdString().c_str());
+    }
+    fTabWidget->currentWidget()->repaint();
+  }
+}
+
 
 
Index: trunk/source/interfaces/common/src/G4Qt.cc
===================================================================
--- trunk/source/interfaces/common/src/G4Qt.cc	(revision 1158)
+++ trunk/source/interfaces/common/src/G4Qt.cc	(revision 1163)
@@ -78,5 +78,6 @@
 ,char** a_args
  ,char*  /*a_class */
-)
+ )
+:fG4UI(NULL)
 /***************************************************************************/
 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
@@ -210,4 +211,7 @@
 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
 {
+#ifdef G4DEBUG_INTERFACES_COMMON
+    printf("G4Qt::SetG4UI \n");
+#endif
   fG4UI = ui;
 }
@@ -221,5 +225,5 @@
 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
 {
-  if (fG4UI) {
+  if (fG4UI != NULL) {
     fG4UI->AddTabVisWidget(vis,name);
     return true;
