Qt3D Repeater and Loader bug – Part 1

While developing Tepee3D, we encountered a few bugs with the Qt3D module. Of course this is not something surprising as it is rather new and not officially part of the Qt 5.0 release yet. However, when having tight deadlines, waiting for someone else to solve them is not something to consider, especially when these bugs stop you and your team from progressing on your tasks. Trying to solve them and contribute to an open source project is a better way to handle such situations.

The first bug we discovered was a bug that prevented Item3D used in Qml Repeater or Listview Items to be seen on screen. In addition, Qml files containing Qt3D Items could not be dynamically loaded using the Loader element.

As we are using C++ models that we exposed to the Qml context to visually represent rooms on a 3D space, having this feature was important.

Here is a simple Qml sample that can be used to reproduce the bug :

import QtQuick 2.0
import Qt3D 2.0
import Qt3D.Shapes 2.0

    id : myModel
    ListElement {x : 10; y : 0; z : 10}
    ListElement {x : -10; y : 0; z : -10}
    ListElement {x : -10; y : 0; z : 10}

    model : myModel
    delegate : myDelegate

    id : myDelegate
      position : Qt.vector3d(model.x, model.y, model.z)
        id : myLoader

Opening the Qt3D source code for the first time is quite impressive. But once you know how it is organized and where to look, you have a chance to solve some bugs.

The source code is available at http://qt.gitorious.org/qt/qt3d

In this case, as our bug seemed to be something regarding only the Qml aspect of Qt3D or QtQuick3D if your prefer, looking in the quick3d directory of the sources seemed a good way to start.

The next step is looking at the code, trying to gasp how it works and how its classes interact. Quite often you’ll think you’ve found the source of a given bug by just looking at some piece of code. Most of the time it is because when you try to understand some code that you have not written yourself, you have a more critical eye. On the other hand, when you just don’t understand the code written, it gets more complicated. We will see more in the next part, but I’ll give two clues for those interested before giving my fix. Look into the qquickitem3d.cpp files and try to understand how Item3D are drawn in the Viewport. Searching through viewport.cpp in the import directory, more closely at the beforeRendering method might also give you some inside knowledge on how Qt3D elements are drawn.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s