#include #include #include #include #include #include int main(int argc, char *argv[]) { QTemporaryFile tempFile; tempFile.open(); QImage outputImg(QSize(30,30), QImage::Format_Grayscale8); outputImg.fill(QColor("black")); QList positions; positions << 0 << std::numeric_limits::max() << std::numeric_limits::max(); for(qint64 pos: positions) { qDebug() << "Seeking to " << pos; tempFile.seek(pos); QImageWriter w((QIODevice*)&tempFile, "bmp"); w.write(outputImg); qDebug() << "Wrote from " << pos << " to " << tempFile.pos(); Q_ASSERT(tempFile.pos() > pos); // Now go back to where we wrote it and read it tempFile.seek(pos); qDebug() << "Reading from " << pos; QImageReader r((QIODevice*)&tempFile, "bmp"); QImage resultImg = r.read(); Q_ASSERT(!resultImg.isNull()); qDebug() << "Read from " << pos << " to " << tempFile.pos(); Q_ASSERT(tempFile.pos() > pos); } qDebug() << "Done"; return 0; }