[Qt-interest] QThread question
Tolik Piskov
tolik.piskov at gmail.com
Thu Dec 3 14:18:37 CET 2009
I need to implement a thread that will be constantly checking network
connection. It will look something like this:
class PingThread: public QThread
{
public:
PingThread(QObject *parent);
void run();
signal:
void ok();
void fail();
}
...
void run()
{
while(true)
{
if ( ping() )
emit ok();
else
emit fail();
Sleep(1000);
}
}
What I also going to do, is to stop and start this thread from my
application several times. Usually I added bool variable bStop with default
value 'false' and a signal to set it to 'true'. And then I simply checked
its value in while() loop.
Is it appropriate or there's some qt-way I must read about?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091203/28127b21/attachment.html
More information about the Qt-interest-old
mailing list