Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. error: unknown type name 'QBuffer'; did you mean 'Qt3DRender::QBuffer'?

error: unknown type name 'QBuffer'; did you mean 'Qt3DRender::QBuffer'?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 895 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    m3g1dd
    wrote on 6 Feb 2021, 07:08 last edited by
    #1

    I have this code:

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

    My qmake project file *.pro contains:

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

    I'm receiving this error:

    error: unknown type name 'QBuffer'; did you mean 'Qt3DRender::QBuffer'?
    qbuffer.h:56:31: note: 'Qt3DRender::QBuffer' declared here

    What I'm doing wrong?

    Error screenshot

    1 Reply Last reply
    0
    • M Offline
      M Offline
      m3g1dd
      wrote on 6 Feb 2021, 07:16 last edited by
      #2

      The error got resolved by replacing:

      #include <QBuffer>
      

      with:

      #include <QtCore/QBuffer>
      

      Not sure why? Namespace conflict?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 6 Feb 2021, 07:24 last edited by
        #3

        Hi,

        Do you have only the code model that is screaming at you ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        M 1 Reply Last reply 6 Feb 2021, 14:18
        0
        • S SGaist
          6 Feb 2021, 07:24

          Hi,

          Do you have only the code model that is screaming at you ?

          M Offline
          M Offline
          m3g1dd
          wrote on 6 Feb 2021, 14:18 last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0

          1/4

          6 Feb 2021, 07:08

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved