Qt World Summit: Submit your Presentation

Box2D integration with QGraphicsView

  • Hi.
    I want to use Box2D with qgraphicsview items.
    I converted box2d cmake project to qmake pro file and added to my project tree.
    I googled a lot but there are tutorials for QML, not qgraphicsview.
    I found this post. but it's too old, does not work, and I don't understand that well :)

    I want to create a top-down project. 4 boxes that create a rectangle and some circles inside that rectangle. Then moving balls in first frame. But they don't hit the walls and go outside.

    Please help me how to map to/from box2d items and qgraphicsitems.
    I can post source code if needed.

    PS. I don't know how to map box2d rectangles to qgraphicsitems so I can't see the boxes :)


  • I join the question. Is there any example using Box2d in Qt5 that would run multiplatform ?


    If not what is the best way to implement physics of colliding and bouncing balls that would also react to gravity ?

  • Lifetime Qt Champion


    There's the QML-Box2D project that can be of interest (Link fixed in the Wiki) that is cross-platform.

    However, I'm not aware of an implementation for the graphics view framework.

Log in to reply