The IrrlichtWidget class is a widget which allows you to use Irrlicht in Qt. It inherits from Qt's QWidget class.
This library requires Qt5, Irrlicht and C++11 or later to work. You can download Qt here and Irrlicht here.
Start by downloading the file irrlichtwidget.h and save it in the same folder as your project source code.
Download the file irrlichtwidget.h, save it to the folder containing your project source code, add it to your project and write #include "irrlichtwidget.h"
in each file where you want to use the widget. You also need to add Irrlicht to your project, to do so in Qt Creator, add the following code to your .pro file, replacing (IRRLICHTPATH)
with the path where you installed Irrlicht and (YOUR OS)
with either Win64-visualstudio, Win32-visualstudio, Linux or MacOSX:
INCLUDEPATH += "(IRRLICHTPATH)/include"
LIBS += "(IRRLICHTPATH)/lib/(YOUR OS)" -lIrrlicht
Also, if you're using Windows, don't forget to copy Irrlicht.dll to the build directory. You can download Irrlicht.dll here for 32-bit programs and here for 64-bit programs. These Irrlicht.dll files are the same as the ones made by Irrlicht.
-
IrrlichtWidget(irr::u32 width = 600, irr::u32 height = 400, irr::video::E_DRIVER_TYPE driverType = irr::video::EDT_OPENGL, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags())
Creates an Irrlicht widget with width
width
, heightheight
, Irrlicht driver typedriverType
, parent widgetparent
and window flagsf
. -
IrrlichtWidget(QSize size, irr::video::E_DRIVER_TYPE driverType = irr::video::EDT_OPENGL, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags())
Same as constructor (1) but allows you to specify the widget size as a
QSize
instead of two integers. -
IrrlichtWidget(irr::video::E_DRIVER_TYPE driverType, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags())
Same as constructor (1) with the width parameter equal to 600 and the height parameter equal to 400.
-
IrrlichtWidget(irr::u32 width, irr::u32 height, QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags())
Same as contructor (1) with the driverType parameter equal to
irr::video::EDT_OPENGL
. -
IrrlichtWidget(QSize size, QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags())
Same as contructor (2) with the driverType parameter equal to
irr::video::EDT_OPENGL
. -
IrrlichtWidget(QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags())
Same as constructor (1) with the width parameter equal to 600, the height parameter equal to 400 and the driverType parameter equal to
irr::video::EDT_OPENGL
.
-
260 methods inherited from
QWidget
. See http://doc.qt.io/qt-5/qwidget.html#public-functions. -
bool paused() const
Returns
true
if the widget is paused andfalse
otherwise. See also the slotsvoid setPaused(bool paused)
,void pause()
andvoid resume()
. -
irr::IrrlichtDevice *getIrrlichtDevice() const
Returns the Irrlicht device associated to the widget.
-
20 slots inherited from QWidget. See http://doc.qt.io/qt-5/qwidget.html#public-slots.
-
void setPaused(bool paused)
If
paused
istrue
, pauses the Irrlicht widget so that nothing moves in it. Ifpaused
isfalse
, unpauses the Irrlicht widget. -
void pause()
Same as
setPaused(true)
. -
void resume()
Same as
setPaused(false)
.
-
5 signals inherited from QWidget. See http://doc.qt.io/qt-5/qwidget.html#signals.
-
void inIrrlichtEventLoop()
This signal is emitted whenever the Irrlicht event loop should be run. The following code with the Irrlicht widget:
QObject::connect(irrlichtWidget, &IrrlichtWidget::inIrrlichtEventLoop, [](){ //whatever });
is the same as the following code in plain Irrlicht:
while(device->run()){ //whatever }
You don't have to call
device->run()
with the Irrlicht widget, it is already called internally.
-
16 static methods inerited from QWidget. See http://doc.qt.io/qt-5/qwidget.html#static-public-members.
-
static void showMessageBox(std::function<void(QMessageBox::StandardButton)> lambda, QWidget *parent, const QString &title, const QString &text, QMessageBox::Icon icon = QMessageBox::Information, QFlags<QMessageBox::StandardButton> buttons = QMessageBox::Ok)
Shows a message box with parent widget
parent
, window titletitle
, messagetext
, iconicon
and buttonsbuttons
, and runslambda
after the message box was closed. This static method is similar toQMessageBox::information
etc, but theQMessageBox
static methods make the Irrlicht widget become black while they are open. -
static void showMessageBox(QWidget *parent, const QString &title, const QString &text, QMessageBox::Icon icon = QMessageBox::Information, QFlags<QMessageBox::StandardButton> buttons = QMessageBox::Ok)
Same as
showMessageBox([](){}, parent, title, text, icon, buttons)
.
You can download an example Qt project which uses the Irrlicht widget here.