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. How to pass slot as parameter?
Forum Updated to NodeBB v4.3 + New Features

How to pass slot as parameter?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.6k Views 1 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.
  • W Offline
    W Offline
    whynoitwork
    wrote on last edited by
    #1

    I don't understand how to do this like for example:

    @void RequestMessage(SLOT *callback)
    {
    callback.Call(data);
    }@

    I want someone to be able to specify a function on which they get the callback.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      SLOT is a "function":http://qt-project.org/doc/qt-5/signalsandslots.html#slots. It can either member of a class or standalone function.

      If you need to pass a slot to another function then declare that another function with pointer to a slot-function as a parameter and then call that parameter. An example with member function:
      @
      class A
      {
      ...
      public slots:
      void foo(int);
      ...
      };

      void otherFunction(void (A::*param)(int))
      {
      *param(10);
      }
      @

      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