The received(QByteArray) problem sounds a lot like having an abstract "connection", a data transport over some low level protocol.
In which case the most natural design IMHO is to model that into classes and keep the QIODevice hidden/encapsulated.
Something like
{
public:
Q_SIGNALS:
public Q_SLOTS:
private Q_SLOTS:
void onReadyRead();
private:
};
class Connection : public QObject
{
public:
explicit Connection(QIODevice *device, QObject *parent = 0);
Q_SIGNALS:
void received(const QByteArray &data);
public Q_SLOTS:
void send(const QByteArray &data);
private Q_SLOTS:
void onReadyRead();
private:
QIODevice *m_device;
};
To copy to clipboard, switch view to plain text mode
Or even have different sub types depending on QIODevice type, potentially letting the subclass create the correct QIODevice, etc.
Cheers,
_
Bookmarks