Qt World Summit: Submit your Presentation

[solved]callback in Qt class

  • Hello, I have a simple question !
    I m using Box2D library in my Qt application.
    I need to use this function : void Query (b2QueryCallback *callback, const b2AABB &aabb)
    How can I create a callback in my my C++ class ?


    void MyClass::test()


    void MyClass::explosition()

    mWorld->query(test, aabb);



    I m sure it's pretty easy.. But I never used callback function in C++ ...

    EDIT: moved to C++ Gurus, as this is not Qt related..., Gerolf

  • Hi dridk,

    I don't know Box2D, but there are only 2 possibilities:

    b2QueryCallback is a function definition, then you must use a function (not a member) as callback.

    b2QueryCallback is a C++ interface, then you class must derive from this interface and implement it.

    I googled for this name and found, "it's a class":http://programanddesign.com/box2d/classb2QueryCallback.html so just derive your C++ class from that class and implement the needed methods.

  • Ok, It was so simple! Thanks

Log in to reply