MIRA
Public Slots | Public Member Functions | Static Public Member Functions | List of all members
SignalBinder Class Reference

Class that provides different slots with different parameters. More...

#include <widgets/SignalBinder.h>

Inheritance diagram for SignalBinder:
Inheritance graph
[legend]

Public Slots

void slot ()
 
void slot (int val)
 
void slot (const QString &val)
 

Public Member Functions

 SignalBinder (QObject *parent)
 
void bind (boost::function< void()> f)
 binds the given function to the slot "slot()" More...
 
void bindInt (boost::function< void(int)> f)
 binds the given function to the slot "slot(int)" More...
 
void bindQString (boost::function< void(const QString &)> f)
 binds the given function to the slot "slot(const QString&)" More...
 

Static Public Member Functions

static SignalBinderconnect (QObject *sender, const char *signal, boost::function< void()> function)
 Create a SignalBinder instance and binds the specified 'signal' of the 'sender' to the specified function. More...
 
template<typename Class >
static SignalBinderconnect (QObject *sender, const char *signal, void(Class::*method)(), Class *instance)
 Create a SignalBinder instance and binds the specified 'signal' of the 'sender' to the specified 'method' of the given class 'instance'. More...
 
static SignalBinderconnect (QObject *sender, const char *signal, boost::function< void(int)> function)
 Create a SignalBinder instance and binds the specified 'signal' of the 'sender' to the specified function. More...
 
template<typename Class >
static SignalBinderconnect (QObject *sender, const char *signal, void(Class::*method)(int), Class *instance)
 Create a SignalBinder instance and binds the specified 'signal' of the 'sender' to the specified 'method' of the given class 'instance'. More...
 
static SignalBinderconnect (QObject *sender, const char *signal, boost::function< void(const QString &)> function)
 Create a SignalBinder instance and binds the specified 'signal' of the 'sender' to the specified function. More...
 
template<typename Class >
static SignalBinderconnect (QObject *sender, const char *signal, void(Class::*method)(const QString &), Class *instance)
 Create a SignalBinder instance and binds the specified 'signal' of the 'sender' to the specified 'method' of the given class 'instance'. More...
 

Detailed Description

Class that provides different slots with different parameters.

For each such slot a boost function can be bound that is called if the slot is invoked. This mechanism can be used as workaround since Qt MOC is not able to handle templates.

Instead of Qt's connect: connect(button, SIGNAL(clicked()), this, SLOT(method()); you can use: SignalBinder::connect(button, SIGNAL(clicked()), &MyClass::method, this);

Example how to use arbitrary bound methods: SignalBinder* s = new SignalBinder(this); s.bind(myMethod); connect(someWidget,SIGNAL(someSignal(int)), s, SLOT(slot(int)));

Constructor & Destructor Documentation

◆ SignalBinder()

SignalBinder ( QObject *  parent)
inline

Member Function Documentation

◆ bind()

void bind ( boost::function< void()>  f)
inline

binds the given function to the slot "slot()"

◆ bindInt()

void bindInt ( boost::function< void(int)>  f)
inline

binds the given function to the slot "slot(int)"

◆ bindQString()

void bindQString ( boost::function< void(const QString &)>  f)
inline

binds the given function to the slot "slot(const QString&)"

◆ slot [1/3]

void slot ( )
inlineslot

◆ slot [2/3]

void slot ( int  val)
inlineslot

◆ slot [3/3]

void slot ( const QString &  val)
inlineslot

◆ connect() [1/6]

static SignalBinder* connect ( QObject *  sender,
const char *  signal,
boost::function< void()>  function 
)
inlinestatic

Create a SignalBinder instance and binds the specified 'signal' of the 'sender' to the specified function.

This variant is for method with the signature 'void method()'.

◆ connect() [2/6]

static SignalBinder* connect ( QObject *  sender,
const char *  signal,
void(Class::*)()  method,
Class instance 
)
inlinestatic

Create a SignalBinder instance and binds the specified 'signal' of the 'sender' to the specified 'method' of the given class 'instance'.

This variant is for method with the signature 'void method()'.

◆ connect() [3/6]

static SignalBinder* connect ( QObject *  sender,
const char *  signal,
boost::function< void(int)>  function 
)
inlinestatic

Create a SignalBinder instance and binds the specified 'signal' of the 'sender' to the specified function.

This variant is for method with the signature 'void method(int)'.

◆ connect() [4/6]

static SignalBinder* connect ( QObject *  sender,
const char *  signal,
void(Class::*)(int)  method,
Class instance 
)
inlinestatic

Create a SignalBinder instance and binds the specified 'signal' of the 'sender' to the specified 'method' of the given class 'instance'.

This variant is for method with the signature 'void method(int)'.

◆ connect() [5/6]

static SignalBinder* connect ( QObject *  sender,
const char *  signal,
boost::function< void(const QString &)>  function 
)
inlinestatic

Create a SignalBinder instance and binds the specified 'signal' of the 'sender' to the specified function.

This variant is for method with the signature 'void method(const QString&)'.

◆ connect() [6/6]

static SignalBinder* connect ( QObject *  sender,
const char *  signal,
void(Class::*)(const QString &)  method,
Class instance 
)
inlinestatic

Create a SignalBinder instance and binds the specified 'signal' of the 'sender' to the specified 'method' of the given class 'instance'.

This variant is for method with the signature 'void method(const QString&)'.


The documentation for this class was generated from the following file: