Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFile setting a timeout
Forum Updated to NodeBB v4.3 + New Features

QFile setting a timeout

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    updatelee
    wrote on last edited by
    #1

    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)) {
    return;
    }
    QByteArray buffer;
    while (stime.elapsed() < 2000 && buffer.size() < BUFFY*10) {
    msleep(10);
    buffer.append(dvr_fd->read(BUFFY));
    }
    @
    Is there a way to set the timeout so that it doesnt get hung up and make me force close the application

    Chris Lee

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved