问题描述
destroy()
我的 qmake 项目文件 #include <QBuffer>
// ---
QString m_parentName;
// ---
QString path = QDir::tempPath();
path = path + "/" + "temp-" + m_parentName + ".stl";
QFile file;
file.setFileName(path);
file.resize(0); // Clear file contents if any
file.open(qiodevice::Append);
// Clear and add 80 bytes of header to QByteArray
QByteArray temp_ba;
QBuffer tmpBuffer(&temp_ba); // => error: unkNown type name 'QBuffer'; did you mean 'Qt3DRender::QBuffer'?
tmpBuffer.open(qiodevice::Append);
tmpBuffer.write("Generated by: " // 14 bytes
"My Nice App" // 11 bytes
"My Nice App" // 11 bytes
"My Nice App" // 11 bytes
"My Nice App" // 11 bytes
"My Nice App" // 11 bytes
"My Nice App" // 11 bytes,80);
file.write(temp_ba);
file.flush();
tmpBuffer.close();
包含:
*.pro
我收到此错误:
错误:未知类型名称“QBuffer”;你的意思是'Qt3DRender::QBuffer'? qbuffer.h:56:31: 注意:'Qt3DRender::QBuffer' 在这里声明
我做错了什么?
解决方法
通过替换解决了错误:
#include <QBuffer>
与:
#include <QtCore/QBuffer>
不知道为什么?命名空间冲突?