Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Invokable and pure virtual method(s)
Forum Updated to NodeBB v4.3 + New Features

Invokable and pure virtual method(s)

Scheduled Pinned Locked Moved Solved General and Desktop
invokablevirtualqobject
13 Posts 5 Posters 9.4k Views 3 Watching
  • 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.
  • R raven-worx
    18 Jan 2016, 14:17

    base class is enough.
    Since in the end the meta object calls the method as you would do, thus the same rules apply ;)

    K Offline
    K Offline
    kshegunov
    Moderators
    wrote on 18 Jan 2016, 14:24 last edited by kshegunov
    #3

    @raven-worx
    Thanks for clarifying that, I suspected as much. What about the first part of the question? Will the moc be clever enough to recognize the Q_INVOKABLE macro without the Q_OBJECT meta-object information? I need only to schedule a queued call through the event loop, I won't need all the QObject's bells and whistles?

    Read and abide by the Qt Code of Conduct

    1 Reply Last reply
    0
    • H Offline
      H Offline
      Hamed.Masafi
      wrote on 18 Jan 2016, 15:19 last edited by
      #4

      No, base class MUST BE inherits from QObject and QObject MUST BE declared in first place of base classes. In this case you can put Q_OBJECT macro into the class.

      Remote object sharing (OO RPC)
      http://forum.qt.io/topic/60680/remote-object-sharing-oo-rpc-solved

      Advanced, Powerful and easy to use ORM for Qt5
      https://forum.qt.io/topic/67417/advanced-powerful-and-easy-to-use-orm-for-qt5

      R 1 Reply Last reply 19 Jan 2016, 06:55
      -1
      • H Hamed.Masafi
        18 Jan 2016, 15:19

        No, base class MUST BE inherits from QObject and QObject MUST BE declared in first place of base classes. In this case you can put Q_OBJECT macro into the class.

        R Offline
        R Offline
        raven-worx
        Moderators
        wrote on 19 Jan 2016, 06:55 last edited by
        #5

        @Hamed.Masafi said:

        No, base class MUST BE inherits from QObject and QObject MUST BE declared in first place of base classes. In this case you can put Q_OBJECT macro into the class.

        that's simply not true!!
        For such cases there is the Q_GADGET macro.

        --- 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

        K 1 Reply Last reply 19 Jan 2016, 11:40
        1
        • R raven-worx
          19 Jan 2016, 06:55

          @Hamed.Masafi said:

          No, base class MUST BE inherits from QObject and QObject MUST BE declared in first place of base classes. In this case you can put Q_OBJECT macro into the class.

          that's simply not true!!
          For such cases there is the Q_GADGET macro.

          K Offline
          K Offline
          kshegunov
          Moderators
          wrote on 19 Jan 2016, 11:40 last edited by kshegunov
          #6

          @raven-worx
          Superb, thank you! I didn't know about the Q_GADGET macro, it must be new in Qt5.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 19 Jan 2016, 12:25 last edited by
            #7

            @kshegunov Nop, it's older than that ;) Q_GADGET dates back to Qt 4

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            K 1 Reply Last reply 19 Jan 2016, 12:27
            0
            • S SGaist
              19 Jan 2016, 12:25

              @kshegunov Nop, it's older than that ;) Q_GADGET dates back to Qt 4

              K Offline
              K Offline
              kshegunov
              Moderators
              wrote on 19 Jan 2016, 12:27 last edited by
              #8

              @SGaist
              Huh, thanks for the clarification. It's possible, although I never knew. Always something new to see, always something new to learn, I guess ... :)

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 19 Jan 2016, 12:34 last edited by
                #9

                There are lots of hidden gems to discover even after years of using Qt :)

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                K 1 Reply Last reply 19 Jan 2016, 12:35
                1
                • S SGaist
                  19 Jan 2016, 12:34

                  There are lots of hidden gems to discover even after years of using Qt :)

                  K Offline
                  K Offline
                  kshegunov
                  Moderators
                  wrote on 19 Jan 2016, 12:35 last edited by
                  #10

                  @SGaist
                  I second that!

                  Read and abide by the Qt Code of Conduct

                  K 1 Reply Last reply 3 Feb 2016, 07:00
                  0
                  • K kshegunov
                    19 Jan 2016, 12:35

                    @SGaist
                    I second that!

                    K Offline
                    K Offline
                    kshegunov
                    Moderators
                    wrote on 3 Feb 2016, 07:00 last edited by
                    #11

                    @raven-worx @SGaist
                    Hello again,
                    Is it possible to have queued invocation on a gadget object? I can't seem to find such a thing. I'm currently retrieving the method itself by:

                    QMetaObject & metaObject = AgDialPrivate::staticMetaObject;
                    QMetaMethod scheduleChildAdd = metaObject.method(metaObject.indexOfMethod("scheduleChildAdd"));
                    

                    however, it looks like QMetaMethod::invokeOnGadget doesn't accept Qt::ConnectionType. Should I try out Q_PRIVATE_SLOT instead?

                    Kind regards.

                    Read and abide by the Qt Code of Conduct

                    T 1 Reply Last reply 3 Feb 2016, 11:04
                    0
                    • K kshegunov
                      3 Feb 2016, 07:00

                      @raven-worx @SGaist
                      Hello again,
                      Is it possible to have queued invocation on a gadget object? I can't seem to find such a thing. I'm currently retrieving the method itself by:

                      QMetaObject & metaObject = AgDialPrivate::staticMetaObject;
                      QMetaMethod scheduleChildAdd = metaObject.method(metaObject.indexOfMethod("scheduleChildAdd"));
                      

                      however, it looks like QMetaMethod::invokeOnGadget doesn't accept Qt::ConnectionType. Should I try out Q_PRIVATE_SLOT instead?

                      Kind regards.

                      T Offline
                      T Offline
                      ttuna
                      wrote on 3 Feb 2016, 11:04 last edited by
                      #12

                      @kshegunov
                      AFAIK gadgets doesn't support signal / slot therefore only a direct call is possible.

                      K 1 Reply Last reply 3 Feb 2016, 15:58
                      0
                      • T ttuna
                        3 Feb 2016, 11:04

                        @kshegunov
                        AFAIK gadgets doesn't support signal / slot therefore only a direct call is possible.

                        K Offline
                        K Offline
                        kshegunov
                        Moderators
                        wrote on 3 Feb 2016, 15:58 last edited by kshegunov 2 Mar 2016, 16:00
                        #13

                        @ttuna
                        Hello,
                        Thanks, I know that. I wanted to have a method of my private object to be queued for later execution, because the ChildAdded event that I'm handling in an event filter is propagated before the child object is fully constructed. It appears that the gadgets have no such capability so I've implemented the functionality as a private slot, and it works okay. For anyone that might be interested, here's how:

                        class AGUI_API AgDial : public QStackedWidget
                        {
                            Q_OBJECT
                            // ...
                        
                        private:
                            Q_PRIVATE_SLOT(d(), void scheduleChildAdd(QPointer<QObject>))
                        };
                        

                        With the corresponding invocation in the event filter:

                        bool AgDial::eventFilter(QObject * object, QEvent * event)
                        {
                            switch (event->type())
                            {
                            case QEvent::ChildAdded:
                                QMetaObject::invokeMethod(this, "scheduleChildAdd", Qt::QueuedConnection, Q_ARG(QPointer<QObject>, QPointer<QObject>(reinterpret_cast<QChildEvent *>(event)->child())));
                                break;
                                // ...
                            }
                        }
                        

                        Kind regards.

                        Read and abide by the Qt Code of Conduct

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved