[Qt-interest] signal and slot
yanqzhi at gmail.com
yanqzhi at gmail.com
Tue Mar 2 10:26:39 CET 2010
I am sorry to answer to you directly.
class A
{
......
signals:
void signal1();
void signal2();
public:
void function()
{
B *b = new B();
connect(this, SIGNAL( signal1() ) ), b, SLOT( slot1() ) );
connect(this, SIGNAL( signal2() ) ), b, SLOT( slot2() ) );
emit signal1();
emit signal2();
}
}
class B
{
........
public slots:
void slot1()
{
//read database;
}
void slot2()
{
//show data read by slot1;
}
public:
void function1()
{
slot1();
}
}
When the funtion in the class A executes, the siganl1 and signal2 will be emitted.
I want that signal2 will be emitted until the excution of slot1 finish.
if use your method when function1 in the class B excutes, the slot2 in class will excutes;
I want to know there is a funtion or some method like SendMessage in MFC which sends a message
and waits until the message has been processed;
Best regards,
yan
yanqzhi at gmail.com
2010-03-02
======= 2010-03-02 11:06, your message: Re: [Qt-interest] signal and slot=======
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/20100302/4497bc94/attachment.html
More information about the Qt-interest-old
mailing list