[Qt-interest] QThread::sleep static protected
Patric
userqt at gmail.com
Sun May 31 14:59:29 CEST 2009
Well, I'm sending some UDP packages on the wire. And I need if there is no
response 5 seconds, the function to exit with error code. That's why I need
a timeout. The application is UI interface.
Regards,
Patric
----- Original Message -----
From: "Karol Krizka" <kkrizka at gmail.com>
To: "Patric" <userqt at gmail.com>
Cc: <qt-interest at trolltech.com>
Sent: Sunday, May 31, 2009 3:48 PM
Subject: Re: [Qt-interest] QThread::sleep static protected
> Hi there,
>
> 2009/5/31 Patric <userqt at gmail.com>:
>> Hello,
>> I'm trying to sleep my thread for 5 seconds and I tried to use
>> QThread::sleep. But it's protected and it seems I can't use it.
>> QThread::sleep(5); for example.
>>
> A google search turns up this thread:
> http://lists.trolltech.com/qt-interest/2007-01/thread00133-0.html
>
> It seems that you will have to implement your own sleep function.
> However, there is also an earlier thread:
> http://lists.trolltech.com/qt-interest/2005-08/thread00071-0.html
> According to it, it is not a good idea to pause an interactive
> application like those build with Qt, and I tend to agree with that.
> However, that argument does not work with console applications, which
> Qt supports. If that is the case, did you think about using the
> standard C sleep() function?
>
>> What's the best way to pause my program for 5 seconds, I'm trying to
>> implement a timeout.
>>
> What do you mean you're trying to implement a timeout? Are you trying
> to do some task (ei: connect somewhere), and if it does not succeed in
> a certain time, then kill it and inform the user? If so, I don't think
> pausing the program for 5 seconds is a good idea. What if the task
> completes before 5 seconds are up? Plus this will keep your
> application in an unresponsive state (including no redraws).
>
> --
> Cheers,
> Karol Krizka
> http://www.krizka.net
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 4098 (20090522) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4098 (20090522) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
More information about the Qt-interest-old
mailing list