Hi!
I'm just wonder how people normally do when they have a instance A lying in a instance B which lies in Frame C. Instance D lies in C and needs signals from A. But since A is not known by C or D, the signal from A must be passed by B... do I need to do like this:
( excuse the bad indentation on the code, I've tried to prettify it )
who knows who:
A<------B<------- [C]--------->D
propagation of signal a1:
[A: send SIGNAL a1 ]->[B: recieve in SLOT, pass SIGNAL b1 (saying the same thing)]-------------->D[recieves SIGNAL b1 which actually is a1]
/** class A ******************/
class A{
signals:
void a1();
}; class A
/** class B *******************/
class B{
/** connect in constructor */
B( )
{
connect ( &a, SIGNAL(a1()), this, SLOT(pass_signalA1()));
}// B ( )
slots:
/** a slot only passing the signal */
void pass_signalA1()
{
emit b1();
}// pass_signalA1()
signals:
/** the signal, actually the a1 signal passed on */
void b1();
A a;
}; // class B
/*** class C **************/
class C{
/** connect B and D */
C ( )
{
connect ( &b, signal(b1()), &d, SLOT(Dslot()));
}// C( )
B b;
D d;
}; //class C
/*** class D *****/
class D{
/** slot recieving the signal b1 */
slots:
void Dslot();
};//class D
/** class A ******************/
class A{
signals:
void a1();
}; class A
/** class B *******************/
class B{
/** connect in constructor */
B( )
{
connect ( &a, SIGNAL(a1()), this, SLOT(pass_signalA1()));
}// B ( )
slots:
/** a slot only passing the signal */
void pass_signalA1()
{
emit b1();
}// pass_signalA1()
signals:
/** the signal, actually the a1 signal passed on */
void b1();
A a;
}; // class B
/*** class C **************/
class C{
/** connect B and D */
C ( )
{
connect ( &b, signal(b1()), &d, SLOT(Dslot()));
}// C( )
B b;
D d;
}; //class C
/*** class D *****/
class D{
/** slot recieving the signal b1 */
slots:
void Dslot();
};//class D
To copy to clipboard, switch view to plain text mode
Maybe I should show some code instead, but I give this a chance.
Bookmarks