【问题标题】:error: unknown type name 'QBuffer'; did you mean 'Qt3DRender::QBuffer'?错误:未知类型名称“QBuffer”;你的意思是“Qt3DRender::QBuffer”吗?
【发布时间】:2021-02-06 07:04:28
【问题描述】:

我有这个代码:

    #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();

我的 qmake 项目文件*.pro 包含:

QT += core gui qml quick quickcontrols2 widgets 3dcore 3drender 3dextras 3dinput 3dlogic 3dquick 3drender-private

我收到此错误:

错误:未知类型名称'QBuffer';你的意思是“Qt3DRender::QBuffer”吗? qbuffer.h:56:31:注意:此处声明了“Qt3DRender::QBuffer”

我做错了什么?

【问题讨论】:

    标签: qt qmake qbuffer


    【解决方案1】:

    通过替换解决了错误:

    #include <QBuffer>
    

    与:

    #include <QtCore/QBuffer>
    

    不知道为什么?命名空间冲突?

    【讨论】:

    • 可能是库版本冲突,afaik 是新样式
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多