CreateRenderWindow() crashed when specify a Qt Window in Ogre
<p>My app is divided into two modules, one is game world driven by Ogre, while another is GUI module implemented using QT.</p>

<p>On app startup I simply create a QApplication instance and a blank QWindow, then I put the QWindow into a Widget. The code look like this:</p>

<p>```</p>

<pre><code>QApplication qapp(argc, argv);
// The class gameworld_widget is just a subclass of QWindow with no other content
ui::gameworld_widget *mainWnd = new ui::gameworld_widget;
QWidget mainWndContainer;
mainWndContainer.setObjectName("OGRE222");
mainWndContainer.resize(800, 600);
mainWndContainer.createWindowContainer(mainWnd);
mainWndContainer.show();
</code></pre>

<p>```</p>

<p>Then I create another thread to create and initilize Ogre Module elsewhere and eventually I pass the 'mainthread' control to Qt. </p>

<p>```</p>

<pre><code>// Get HWND of gameworld_widget in 'main thread'
auto hMainWnd = reinterpret_cast&lt;HWND&gt;(mainWnd-&gt;winId());
std::thread gameWorldThread([hMainWnd]() {
try {
game_world gameWorld(hMainWnd); // see below
}
catch (game_world_exception &amp;ex) {
std::cout &lt;&lt; "GameWorldException occurs\n";
return;
}
});
gameWorldThread.detach(); // detach Ogre thread
return qapp.exec(); // pass control to Qt
</code></pre>

<p>```</p>

<p>In Ogre Module, My code look like this:</p>

<p>```</p>

<pre><code>Ogre::NameValuePairList params;
params["externalWindowHandle"] = Ogre::StringConverter::toString(reinterpret_cast&lt;size_t&gt;(hwnd));
Ogre::RenderWindow *mWindow;
try
{
mWindow = root.createRenderWindow("SampleBrowser", 800, 600, false, &amp;params);
}
catch (Ogre::Exception ex)
{
std::cout &lt;&lt; "Ogre exception occur:" &lt;&lt; typeid(ex).name() &lt;&lt; ex.what() &lt;&lt; "\n";
throw game_world_exception();
}
catch (...)
{
throw game_world_exception(); // comment goes here
}
</code></pre>

<p>```</p>

<p>Here the question comes. When running</p>

<p>```</p>

<pre><code>/* comment goes here */
mWindow = root.createRenderWindow("SampleBrowser", 800, 600, false, &amp;params);
</code></pre>

<p>```</p>

<p>My App is crashed, <strong>I even can't catch the exception</strong>.
<a href="https://i.stack.imgur.com/l9wll.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l9wll.png" alt="enter image description here"></a>
(I'm a chinese so the language is chinese...) The progress bar's content is 'Ogre2.exe has stopped working... Windows is finding the problem'
My system is Windows 10, IDE is visual studio 2015.And Ogre is version 1.8, Qt is 5.7.0. The choosen Ogre Render system is OpenGL</p>