title: How to close a Qml window when creating a QGLWidget
body: <p>I am trying to build a game in which the ui part is made in qml (menu etc) while the rendering and logic part is in C++. For this I'm using a QGLWidget subclass. The game starts with Qml (using a QDeclarativeContext in the main function) and on clicking 'NewGame', I am loading my QGLWidget subclass.  Something like this:</p>
  
  <pre><code>GameButton{
      id:button2_1_1
      x: 69
      y: 101
      width: 80
      height: 80
      onClicked:{ myObject.initialize(); myObject.show(); }
  }
  // myObject sets the context property to the object of my QGLWidget subclass
  </code></pre>
  
  <p>The problem is that I can't figure out a way to close my Qml window when I load the QGLWidget. As with what I've done two windows are displayed simultaneously.  </p>
  
  <p>Here's the code for it.</p>
  
  <p>// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
      import QtQuick 1.1</p>
  
  <pre><code>Rectangle {
  id:newGameMenu
  width: 640
  height: 360
  signal button2Clicked();
  onButton2Clicked: console.log("new game should start")
  
  
  Image{
      id:background
      source:"menubackground.jpg"
      anchors.fill:parent
  
      Button2 {
          id: button21
          x: 70
          y: 101
          width: 42
          height: 42
      }
  }
  
  Button2{
      id:button2_1_1
      x: 69
      y: 101
      width: 44
      height: 44
      onClicked:{ myObject.abc(); myObject.show(); console.log("glwindow called"); }
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>main.cpp
  
  
  #include &lt;QtGui/QApplication&gt;
  #include "qmlapplicationviewer.h"
  #include &lt;QDeclarativeView&gt;
  #include &lt;QDeclarativeItem&gt;
  #ifndef GLWINDOW_H
  #include "glwindow.h"
  #endif
  #include &lt;QObject&gt;
  
  Q_DECL_EXPORT int main(int argc, char *argv[])
  {
      QScopedPointer&lt;QApplication&gt; app(createApplication(argc, argv));
      QDeclarativeView view;
      GLWindow w;
      view.rootContext()-&gt;setContextProperty("myObject", &amp;w);
      view.setSource(QUrl::fromLocalFile(""));
      view.show();
      qDebug() &lt;&lt; "into the qml";
  
  
      return app-&gt;exec();
  </code></pre>
  
  <p>}</p>