Nominate our 2022 Qt Champions!

using shiboken to wrap non-QObject classes

  • hi, I'm just looking into Shiboken and have a question.
    From reading the history of shiboken, I had thought that it could be used to wrap any C++ classes for Python, even those not derived from QObject.

    I realize that to support signals, a class must derive from QObject, but in the case of simple math types, is this still necessary?
    Can I wrap simple class hierarchies and eliminate the dependency on Qt? (hypothetical question).


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    I haven't used shiboken yet but is it that what that question answers ?

  • Hi SGaist, Thanks!.
    Yes, that does answer my question, and in fact I had been skimming through the docs and read those parts already.

    The source of my confusion came from reading this tutorial

    In the example, Math inherits from QObject which didn't seem necessary based on the docs. It could be a simple C++ class with no ancestors. So I thought that maybe in the end there was some dependency on Qt and decided to double-check.

    class Math : public QObject

    There is another tutorial on your website that also covers Shiboken, and I can clearly see that FooClass is not derived from QObject, which confirms your answer.


    I hadn't downloaded the source code for that tutorial till now.
    Thanks for the quick answer.

  • Lifetime Qt Champion

    You're welcome !

    Since everything is ok, please mark the thread as solved using the "Topic Tool" button so other forum users may know a solution has been found :)

    Also, while browsing the forum, consider up-voting answers that helped you. That will make them easier to find for other people :)

Log in to reply