Irrlicht editor with QT
Posted: Sun Feb 17, 2019 8:13 am
I want to write my own irrlicht scene editor with QT.
I create a class QIrrlichtWidget which derived from the QWidget, and reimplement the "paintEvent" mehtod to drive the Irrlicht drawing loop.
but the QT throw the "QWidget::repaint: Recursive repaint detected" exception.
so, I use the Qt timer to avoid using the paintEvent.

It is works well. But, there are still some problems. When I pass the QT mouse events to irrlicht engine, and operate the objects in irrlicht scene, the user experience is too bad. There are some delays that cannot be tolerated.
So, do anyone have any good ideas to solve the problem?
I create a class QIrrlichtWidget which derived from the QWidget, and reimplement the "paintEvent" mehtod to drive the Irrlicht drawing loop.
Code: Select all
//.h
class QIrrlichtWidget : public QWidget
{
signals:
void updateIrrlicht( );
public slots:
void autoUpdateIrrlicht();
protected:
virtual void paintEvent ( QPaintEvent * event );
}
//.cpp
QIrrlichtWidget::QIrrlichtWidget(QWidget *parent) : QWidget(parent)
{
connect( this, SIGNAL(updateIrrlicht()), this, SLOT(autoUpdateIrrlicht()) );
}
void QIrrlichtWidget::paintEvent(QPaintEvent *event)
{
if ( m_device )
{
emit updateIrrlicht( m_device );
}
}
void QIrrlichtWidget::autoUpdateIrrlicht()
{
if(m_device->run())
{
m_device->getTimer()->tick();
m_driver->beginScene(true, true, irr::video::SColor(255,125,0,0));
m_scene->drawAll();
m_guienv->drawAll();
m_driver->endScene();
}
}
so, I use the Qt timer to avoid using the paintEvent.
Code: Select all
QIrrlichtWidget::QIrrlichtWidget(QWidget *parent) : QWidget(parent)
{
connect( this, SIGNAL(updateIrrlicht()), this, SLOT(autoUpdateIrrlicht()) );
startTimer(0);
}
void QIrrlichtWidget::timerEvent(QTimerEvent * event)
{
if ( m_device )
{
emit updateIrrlicht( m_device );
}
event->accept();
}

It is works well. But, there are still some problems. When I pass the QT mouse events to irrlicht engine, and operate the objects in irrlicht scene, the user experience is too bad. There are some delays that cannot be tolerated.
So, do anyone have any good ideas to solve the problem?