I had this problem and I needed to call the XSync
method as shown below. This is part of the OgreWidget::initialize
method, where OgreWidget
subclass of QWidget
. initialize
is called part of building the OgreWidget
, after highlighting m_OgreRoot
and setting the rendering.
setAttribute(Qt::WA_PaintOnScreen, true); setAttribute(Qt::WA_NoSystemBackground, true); setFocusPolicy(Qt::StrongFocus); Ogre::String winHandle; QX11Info info = x11Info(); winHandle = Ogre::StringConverter::toString((unsigned long)(info.display())); winHandle += ":"; winHandle += Ogre::StringConverter::toString((unsigned int)(info.screen())); winHandle += ":"; winHandle += Ogre::StringConverter::toString((unsigned long)(winId())); Ogre::NameValuePairList params; params["parentWindowHandle"] = winHandle; params["FSAA"] = Ogre::String("8"); int w = width(); int h = height(); // Need to call XSync or the window handles will be invalid. XSync(info.display(), False); m_OgreWindow = m_OgreRoot->createRenderWindow("OgreWidget_RenderWindow", qMax(w, 640), qMax(h, 480), false, ¶ms);
Here is the same code modified for Qt 5.1.0. QX11Info
was removed for Qt 5.0.x, then added to the Additional Components component for Qt 5.1.0. The new QX11Info
class has only static methods.
#include <QtX11Extras/QX11Info> ... setAttribute(Qt::WA_PaintOnScreen, true); setAttribute(Qt::WA_NoSystemBackground, true); setFocusPolicy(Qt::StrongFocus); Ogre::String winHandle; winHandle = Ogre::StringConverter::toString((unsigned long)(QX11Info::display())); winHandle += ":"; winHandle += Ogre::StringConverter::toString((unsigned int)(QX11Info::appScreen())); winHandle += ":"; winHandle += Ogre::StringConverter::toString((unsigned long)(winId())); Ogre::NameValuePairList params; params["parentWindowHandle"] = winHandle; params["FSAA"] = Ogre::String("8"); int w = width(); int h = height(); // Need to call XSync or the window handles will be invalid. XSync(QX11Info::display(), False); m_OgreWindow = m_OgreRoot->createRenderWindow("OgreWidget_RenderWindow", qMax(w, 640), qMax(h, 480), false, ¶ms);
source share