Code: Select all
class IrrlichtWidget : public QWidget{
Q_OBJECT
public:
IrrlichtWidget(){
irr::SIrrlichtCreationParameters params;
params.DriverType = irr::video::EDT_OPENGL;
params.WindowId = (void*)winId();
m_device = irr::createDeviceEx(params);
setAttribute(Qt::WA_OpaquePaintEvent);
m_timer = new QTimer;
m_timer->setInterval(0);
QObject::connect(m_timer, &QTimer::timeout, [this](){
m_device->getVideoDriver()->beginScene(true, true, irr::video::SColor(255, 255, 255, 255));
m_device->getSceneManager()->drawAll();
m_device->getVideoDriver()->endScene();
m_device->run();
});
m_timer->start();
}
private:
irr::IrrlichtDevice *m_device;
QTimer *m_timer;
}
Code: Select all
QObject::connect(m_timer, &QTimer::timeout, [this](){
m_device->getVideoDriver()->beginScene(true, true, irr::video::SColor(255, 255, 255, 255));
m_device->getSceneManager()->drawAll();
m_device->getVideoDriver()->endScene();
m_device->run();
QMessageBox::information(this, "Foo", "Bar");
});
To compare, here is exactly the same program with the only difference that it doesn't have a QMessageBox in it:
I tried putting the QMessageBox everywhere in Irrlicht's main loop, at the beginning, at the end, in the middle, and it always does the same thing. It does this for every kind of Qt dialog boxes: QMessageBox, QFileDialog, etc.
I also tried removing the setAttribute(Qt::WA_OpaquePaintEvent) line in the constructor, and then the background was beige instead of black. Not the same color, but still the same problem.
It seems like the QMessageBox is somehow erasing the content of the Irrlicht widget. Why is it doing this? How can I fix it?