QFile setting a timeout

  • Im trying to read from a device and sometimes if data isnt available it gets stuck, not allways but often.

    @ dvr_name = "/dev/dvb/adapter" + QString::number(adapter) + "/dvr0";
    dvr_fd = new QFile(dvr_name);
    if (!dvr_fd->open(QIODevice::ReadOnly|QIODevice::Unbuffered)) {
    QByteArray buffer;
    while (stime.elapsed() < 2000 && buffer.size() < BUFFY*10) {
    Is there a way to set the timeout so that it doesnt get hung up and make me force close the application

    Chris Lee

  • Hi, QSocketNotifier and QTimer can be used in such cases.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.