I guess you should create a subclass of QIODevice and implement all the platform-specific issues by yourself
Something like this:
//ParalellPort.h
#include <QIODevice>
Q_OBJECT
public:
virtual ~ParalellPort();
virtual bool isSequential () const { return true; }
virtual bool open(OpenMode);
virtual void close ();
//..
protected:
virtual qint64 readData ( char * data, qint64 maxSize );
virtual qint64 writeData ( const char * data, qint64 maxSize );
private:
#ifdef Q_OS_UNIX
#endif
};
//ParalellPort.cpp
#include "ParalellPort.cpp"
#ifdef Q_OS_UNIX
, deviceFile(port)
#endif
{
}
bool ParalellPort::open(OpenMode mode) {
#ifdef Q_OS_UNIX
return deviceFile.open(mode);
#endif
#ifdef Q_OS_MACX
//...
#endif
#ifdef Q_OS_WIN32
//...
#endif
}
//...
//ParalellPort.h
#include <QIODevice>
class ParalellPort : public QIODevice {
Q_OBJECT
public:
ParalellPort(const QString &, QObject * = 0);
virtual ~ParalellPort();
virtual bool isSequential () const { return true; }
virtual bool open(OpenMode);
virtual void close ();
//..
protected:
virtual qint64 readData ( char * data, qint64 maxSize );
virtual qint64 writeData ( const char * data, qint64 maxSize );
private:
#ifdef Q_OS_UNIX
QFile deviceFile;
#endif
};
//ParalellPort.cpp
#include "ParalellPort.cpp"
ParalellPort::ParalellPort(const QString & port, QObject * parent) :
QIODevice(parent)
#ifdef Q_OS_UNIX
, deviceFile(port)
#endif
{
}
bool ParalellPort::open(OpenMode mode) {
#ifdef Q_OS_UNIX
return deviceFile.open(mode);
#endif
#ifdef Q_OS_MACX
//...
#endif
#ifdef Q_OS_WIN32
//...
#endif
}
//...
To copy to clipboard, switch view to plain text mode
A quote from TT's docs:
Subclasses of QIODevice are only required to implement the protected readData() and writeData() functions.
Bookmarks