Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. what is reason to use both public slots and a Q_INVOKABLE method. As I can call slots from qml as well and also I can use Q_INVOKABLE method to connect signal.
Forum Updated to NodeBB v4.3 + New Features

what is reason to use both public slots and a Q_INVOKABLE method. As I can call slots from qml as well and also I can use Q_INVOKABLE method to connect signal.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 4 Posters 329 Views
  • 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.
  • K Offline
    K Offline
    KYADAV
    wrote on last edited by
    #1

    Can any one help me on this to explain.

    jsulmJ J.HilkJ 2 Replies Last reply
    0
    • K KYADAV

      Can any one help me on this to explain.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @KYADAV It is explained here: https://doc.qt.io/qt-5/qobject.html
      Q_INVOKABLE is used to be able to call methods of a class using https://doc.qt.io/qt-5/qmetaobject.html#invokeMethod

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • K KYADAV

        Can any one help me on this to explain.

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @KYADAV slots usually return void


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        1
        • K Offline
          K Offline
          KYADAV
          wrote on last edited by
          #4

          Thanks @J-Hilk , @jsulm, appreciated for such a quick response.

          1 Reply Last reply
          0
          • GrecKoG Offline
            GrecKoG Offline
            GrecKo
            Qt Champions 2018
            wrote on last edited by
            #5

            The difference is just a convention now. Both slots and Q_INVOKABLE can be called by invokeMethod and meta-object system. Slots can have a return type.

            What I usually do is use slots for function that modify the state of the object and invokable for helpers returning or transforming data, usually taking some parameters.

            1 Reply Last reply
            1

            • Login

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