[Qt-interest] QT signal and reentrant

邵度 shao.tu at gmail.com
Wed Jun 17 02:16:36 CEST 2009


Thanks everyone who helps me to clarify QT signal/slot mechanism.
I hope, eventually, that I can be familiar with QT like all of you.
Thanks again!



2009/6/16 邵度 <shao.tu at gmail.com>

> Hello,
>
> I am a newbie of QT. Let me starts from the following code segment:
>
> int* getPower(int i)
>   {
>   static int result;
>   result = (int)pow(2, i);
>   sleep(5);
>   return &result;
>   }
>
> void handler (int signal_number)
>   {
>   getPower(3);
>   }
>
> int main ()
>   {
>   int *result;
>   struct sigaction sa;
>   memset(&sa, 0, sizeof(sa));
>   sa.sa_handler = &handler;
>   sigaction(SIGUSR1, &sa, NULL);
>   result = getPower(5);
>   printf("2^5 = %d\n", *result);
>   return 0;
>   }
>
> After executing above program, if I send the signal USR1 to it within 5
> seconds, the output will display "2^5 = 8" as its result.
> This error is due to the behavior while receiving signals in UNIX.
> My question is: will the same situation occur while emiting a QT signal?
> Any why?
> I can't figure it out from QT documentations even if I study it many times.
> Can anyone explain me the detail QT signal/slot mechanism?
>
> Alex
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090617/83e49c4f/attachment.html 


More information about the Qt-interest-old mailing list