
Originally Posted by
ucntcme
Since I wanted it to, naturally.
Actually, I was mislead by statements (elsewhere) that emit was "just a decoration for the programmer", that the signal was still "just a function call".
It is (usually) a function call. But! What happens if there are two or more slots connected to a signal? Return value of which of them should then be returned?
As soon as I figure out just what you mean, I'm sure I'll try it.
I mean to pass a pointer or reference of the object which is to deliver some information to the other one. This way you'll be able to call the method directly on a single object, without signal/slot mechanism:
struct aaa {
int action(someclass &);
};
class bbb {
public:
void registerDeliverer(aaa *a){ m_ad = a; }
void do_something();
private:
aaa *m_ad;
}
void bbb::do_something(){
//...
if(!m_ad)
return;
int act = m_ad->action(); // fetch an int from registered object
//...
}
//...
aaa action_deliverer;
bbb obj;
//...
obj->registerDeliverer(&action_deliverer);
//...
obj->do_something();
//...
struct aaa {
int action(someclass &);
};
class bbb {
public:
void registerDeliverer(aaa *a){ m_ad = a; }
void do_something();
private:
aaa *m_ad;
}
void bbb::do_something(){
//...
if(!m_ad)
return;
int act = m_ad->action(); // fetch an int from registered object
//...
}
//...
aaa action_deliverer;
bbb obj;
//...
obj->registerDeliverer(&action_deliverer);
//...
obj->do_something();
//...
To copy to clipboard, switch view to plain text mode
Bookmarks