[Qt-interest] QFile.waitForReadyRead() not working on dev file
Linus Casassa
linus at lin.cl
Thu Mar 19 00:56:40 CET 2009
Thanks for the help. I made the code work by putting the device.read() on a
thread and killing the thread when I need to change the device :)
class QJoyStick : public QThread
{
...
void QJoyStick::run( );
void QJoyStick::close( );
...
}
void QJoyStick::run( )
{
while( runFlag )
{
if ( device.read( (char*)&data, sizeof(data) ) == sizeof(data) )
{
...
}
}
}
void QJoyStick::close( )
{
terminate();
wait();
device.close();
}
2009/3/18 Thiago Macieira <thiago.macieira at trolltech.com>
> Linus Casassa wrote:
> >waitForReadyRead() always returns 0 without waiting 1 second. It prints
> >thousands of "looping"s.
>
> waitForReadyRead() doesn't do anything in QFile. You have to use
> QSocketNotifier and an event loop if you want to do that. And you must
> understand your code will be non-portable (QSocketNotifier only works on
> sockets on Windows).
>
> --
> Thiago Macieira - thiago.macieira (AT) nokia.com
> Senior Product Manager - Nokia, Qt Software
> Sandakerveien 116, NO-0402 Oslo, Norway
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
--
Linus Casassa
Estudiante Ingeniería Civil Electrónica
Fono: 56-9-97776941
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090318/079c07e7/attachment.html
More information about the Qt-interest-old
mailing list