<Solved> Pointer to Calling class is needed
Hi there,
I've a problem with the old topic "Signal from one class to another class".
To clearify my situation:
I have A which calls B (a modal QDialog, so it is without parent). B has a button, when pressed a function in A is calling, this way works. But the other way round I have the problem...
I initialize B like this:
b = new B();
and later in the "openFunction":
b->setFixedSize(b->minimumSize());
testbshow();
and now, in B I want this:
connect(A, SIGNAL(CallB()), this, SLOT(FunctionB()));
Because B should be Modal I can't do anything like this (maybe, I'm only don't know how I get B modal with this line):
b = new B(this);
I hope someone has a idea what I can do, so that B can get a signal from A.
-casisto
Re: Pointer to Calling class is needed
Quote:
Originally Posted by
Casisto
I have A which calls B (a modal QDialog, so it is without parent).
What does modality have to do with parent/child relationship?
Quote:
Originally Posted by
Casisto
and now, in B I want this:
connect(A, SIGNAL(CallB()), this, SLOT(FunctionB()));
Isn't it way easier to do the connect inside A, where you have both a pointer to A and B?
E.g. right after creating B
Cheers,
_
Re: Pointer to Calling class is needed
Thanks so much!
I didn't know that I can do this so. I ever thought the connect has to been in the class where the function is declared.
Re: Pointer to Calling class is needed
Quote:
Originally Posted by
Casisto
I didn't know that I can do this so. I ever thought the connect has to been in the class where the function is declared.
No, that's the beauty of signal/slots.
Neither the sender nor the receiver need to know about the other or the connect, the connection can be done by any code that knows both objects.
Cheers,
_