[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Calling arbitrary slots
From:       Martijn Klingens <mklingens () yahoo ! com>
Date:       2001-05-18 13:25:01
[Download RAW message or body]

Hi,

I want to maintain a list with RegExps and the associated event handler that 
should be executed when the input mathces the expression. Looking in the Qt 
sources I discovered that slots are actually just a const char *, so I 
created the following class:

class InputFilter
{
public:
  InputFilter( const QString &pattern, QObject * receiver,
                const char * member );
  void exec( QString line );
};

The idea was to run the event handler from exec() in the way e.g. 
QTimer::singleShot does. But that doesn't work because the QSignal that is 
used there doesn't take arguments.

What I want to call is

receiver->member( line );

where member is the name of the member as a usual slot and line is a QString. 
Maybe I need more parameters later on, BTW, but for now the QString suffices.

How can I do this (or what part of Qt does the same thing, so I can look 
there) ? The classes that I tried only emitted their own signals, but I 
couldn't find a place where a signal handler is explicitely called.

The only solution I can think of is emitting a signal from exec that can be 
connected upon object creation time, but that adds an extra line of code to 
each object (the connect) and probably a bit more overhead.

Is there a better solution than that?

TIA,

Martijn
 
>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic