Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Q_GADGET vs Q_OBJECT

    QML and Qt Quick
    3
    5
    13686
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • X
      xylosper last edited by

      I can use Q_GADGET or Q_OBJECT to expose C++ object into QML.
      If my object can be implemented through Q_GADGET, that is no need of inheritance of QObject and no need of signals, which one should I use?
      Should I always prefer Q_GADGET to Q_OBJECT whenever possible?
      Or, is it always better to use Q_OBJECT than Q_GADGET?
      If it depends on situation, what would decide better one?

      raven-worx 1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators @xylosper last edited by raven-worx

        @xylosper
        Q_GADGET is more or less the MOC part of Q_OBJECT.
        So if you can live without the features provided by QObject class you are good to go.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        X 1 Reply Last reply Reply Quote 1
        • Q
          qnope last edited by

          Q_GADGET does not allow signal

          1 Reply Last reply Reply Quote 1
          • X
            xylosper @raven-worx last edited by

            @raven-worx
            In that case, I'll stick to Q_GADGET as much as possible. Thank you!

            @qnope
            I've already mentioned 'no need of signals'. Thank you.

            raven-worx 1 Reply Last reply Reply Quote 1
            • raven-worx
              raven-worx Moderators @xylosper last edited by raven-worx

              @xylosper
              if you are forced to use QObjects derives instead, you most probably will get compile errors anyway.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply Reply Quote 0
              • First post
                Last post