Irrlicht editor with QT

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
kingw
Posts: 2
Joined: Sat Jun 02, 2018 6:34 am

Irrlicht editor with QT

Post by kingw »

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.

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();
    }
}
 
but the QT throw the "QWidget::repaint: Recursive repaint detected" exception.

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();
}
 
 
Image

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?
Post Reply