Home · Modules · Classes · Namespaces · Functions

QxtSlotMapper Class Reference
[QxtCore module]

The QxtSlotMapper class maps signals with a specific parameter value to certain slots. More...

    #include <QxtSlotMapper>

Inherits QObject.

Public Functions

Additional Inherited Members


Detailed Description

The QxtSlotMapper class maps signals with a specific parameter value to certain slots.

QxtSlotMapper is the counterpart of QSignalMapper. Where QSignalMapper maps a parameterless signal into one that has a parameter based on the sender, QxtSlotMapper maps a signal with a parameter to a specified slot and receiver based on that parameter's value. Different slots on potentially different receivers can be invoked by the same signal, according to that parameter.

The parameter comparison is based on QVariant::operator==(). Thus, any built-in Qt type supported by QVariant and QMetaType is supported.

Example usage:

    QxtSlotMapper mapper;
    mapper.connect(sender, SIGNAL(signal1(int)));
    mapper.connect(sender, SIGNAL(signal2(QString)));

    mapper.addMapping(3, receiver1, SLOT(slot1(int)));
    mapper.addMapping(QString("abc"), receiver2, SLOT(slot2(QString)));

See also QVariant, QMetaType::Type, and QSignalMapper.


Member Function Documentation

QxtSlotMapper::QxtSlotMapper ( QObject * parent = 0 )

Constructs a new QxtSlotMapper with parent.

QxtSlotMapper::~QxtSlotMapper ()

Destructs the slot mapper.

void QxtSlotMapper::addMapping ( const QVariant & parameter, QObject * receiver, const char * member )

Adds mapping from connected signals with parameter to receiver's member.

bool QxtSlotMapper::connect ( const QObject * sender, const char * signal )

Connects to sender's signal. Returns true if the connection succeeds and false otherwise.

void QxtSlotMapper::removeMapping ( const QVariant & parameter, QObject * receiver = 0, const char * member = 0 )

Removes mapping from connected signals with parameter to receiver's member.

If member is 0, any mapping with parameter to receiver is removed. If receiver is 0, any mapping with parameter is removed.


Copyright © 2007-2011 Qxt Foundation
Qxt 0.6.2