I would implement a thread that will handle the I/O. You can connect the appropriate sig/slots to "invoke" the IO from your main thread to the IO thread. You can pass the data to be read/written as a parameter to the signal. Something like this:
class FileIOThread : public QThread
{
public:
void run();
public slots:
void writeData(QByteArray &)
void readData(QByteArray &)
};
class MyClass
{
private:
FileIOThread m_writerThread;
signals:
void sendData(QByteArray &);
....
};
MyClass::MyClass()
{
connect(this, SIGNAL(sendData(QByteArray&)),
&m_writerThread,SLOT(writeData(QByteArray&)));
....
}