当我的基类是QIODevice时,我可以重新实现writeData和readData,但如果基类是QFile则它不起作用。 OFile的基类是QFileDevice,QFileDevice的基类是QIODevice:
//This works:
//class xyseriesiodevice : public QIODevice
//This doesn't work
class xyseriesiodevice : public QFile
{
Q_OBJECT
public:
explicit xyseriesiodevice(QXYSeries * series, QObject *parent = 0);
protected:
qint64 readData(char * data, qint64 maxSize);
qint64 writeData(const char * data, qint64 maxSize);
致电
//m_device is of type xyseriesiodevice
//m_audioInput is of type QAudioInput
m_device->open(QIODevice::WriteOnly);
m_audioInput->start(m_device);
来自writeData
的 xyseriesiodevice
仅在基类为QIODevice
时调用
谢谢!
答案 0 :(得分:0)
如果您没有包含QFile库,请尝试包含它。 尝试在方法签名后添加“override”关键字。
qint64 readData(char * data, qint64 maxSize) override;
qint64 writeData(const char * data, qint64 maxSize) override;