History: Integrating Ogre into QT5
Source of version: 7
Copy to clipboard
__Work in Progress__
Original forum link: http://www.ogre3d.org/forums/viewtopic.php?p=515314#p515314
The following document is an up-to-date method of integrating Ogre3D into the latest version of Qt (5.4 as of this writing).
Previous methods of integrating Ogre3D with Qt focused on [http://www.ogre3d.org/tikiwiki/QtOgre|using a QWidget] and overriding the paint methods for drawing.
The method proposed in this document uses a QWindow as opposed to a QWidget. There are several reasons for using a QWindow over a QWidget:
*__Smaller memory and processing footprint__. Simply put, [http://stackoverflow.com/questions/17860604/what-is-the-difference-between-a-qwindow-and-qwidget|QWidgets use a lot of resources in comparison to QWindows] and thus adds a lot of unnecessary overhead. Ogre3D doesn't require much from Qt besides a surface to draw upon and the input/window events from the underlying OS and windowing system that a QWindow provides. As a related sidenote, QWidget actually inherits from QWindow as shown in the below inheritance chain.
*__Easier integration__. Because of the simplicity of QWindow it is actually much easier to integrate Ogre3D into Qt using a QWindow versus using a QWidget. QWidget by default creates a surface to draw on which Ogre3D doesn't need to draw upon. Thus, as shown in earlier Qt-Ogre3D implementation documents you need to override Qt methods to prevent the default QWidget methods from "drawing over" Ogre3D. Using a QWindow this is unnecessary as with a QWindow no "surface" is automatically created; you can simply supply QWindow's native "Window ID" (whether it is a HWND on Windows or the equivalent representations on Linux/Mac OS) and Ogre3D takes care of the rest.
*