[Qt-interest] signal and slot
Malyushytsky, Alex
alex at wai.com
Tue Mar 2 04:06:27 CET 2010
Please answer to the mailing list, not to me directly.
That what exactly what I meant when I asked you do make sure your questions can be understood.
I either fail to understand your problem, or you fail to understand the suggestion.
Assume you have QAction signal triggered which is emitted when user activates menu command.
You have instances of 2 classes:
class A
{
................
signals:
void slotB_isReadyToBeCalled();
public slots:
void onActionTriggered() {
// do something
...
// call B::onActionTriggered() one way or another
#ifdef CALL_B_DIRECTLY
getB_pointer()->B::onActionTriggered();
#else
emit slotB_isReadyToBeCalled();
#endif
};
}
class B
{
................
public slots:
void onActionTriggered();
}
// somewhere in cpp
QObject* a = new A();
QObject* b = new B();
...
bool ok
ok = connect( ui.myAction, SIGNAL( triggered()), a, SLOT(onActionTriggered ()) ); Q_ASSERT( ok );
#if ! defined CALL_B_DIRECTLY
ok = connect( b, SIGNAL(slotB_isReadyToBeCalled ()), b, SLOT(onActionTriggered ()) ); Q_ASSERT( ok );
#endif
// if signal triggered you get both 'a' and 'b' slots onActionTriggered() called and a is called first
Regards,
Alex
From: yanqzhi at gmail.com [mailto:yanqzhi at gmail.com]
Sent: Monday, March 01, 2010 6:40 PM
To: Malyushytsky, Alex
Subject: Re: [Qt-interest] signal and slot
Dear Malyushytsky, Alex,
Yes, I mean that in your email.
But the other function will call the first slot and in this case the second slot will not be called.
Thanks a lot.
Sincerely
yanqzhi at gmail.com
2010-03-02
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
"Please consider our environment before printing this email."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100301/d94aa99a/attachment.html
More information about the Qt-interest-old
mailing list