bool QAbstractSocket::waitForReadyRead(int msecs){... if (!d->socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, true, !d->writeBuffer.isEmpty(), qt_timeout_value(msecs, stopWatch.elapsed()))) { d->socketError = d->socketEngine->error(); setErrorString(d->socketEngine->errorString());#if defined (QABSTRACTSOCKET_DEBUG) qDebug("QAbstractSocket::waitForReadyRead(%i) failed (%i, %s)", msecs, d->socketError, errorString().toLatin1().constData());#endif emit error(d->socketError); if (d->socketError != SocketTimeoutError) close(); return false; } if (readyToRead) { if (d->canReadNotification()) return true; } if (readyToWrite) d->canWriteNotification(); if (state() != ConnectedState) return false; } return false;}
C++ (Qt)int fd = ::open( "/dev/ttyS0", O_RDWR | O_NONBLOCK | O_NOCTTY );QSocketNotifier *readNotifier = new QSocketNotifier( fd, QSocketNotifier::Read );connect( readNotifier, SIGNAL( activated( int ) ), ... );
int fd = ::open( "/dev/ttyS0", O_RDWR | O_NONBLOCK | O_NOCTTY );QSocketNotifier *readNotifier = new QSocketNotifier( fd, QSocketNotifier::Read );connect( readNotifier, SIGNAL( activated( int ) , this, SIGNAL(readyRead() );
C++ (Qt)QSocketNotifier *readNotifier = new QSocketNotifier( fd, QSocketNotifier::Read, this );