Important: Please read the Qt Code of Conduct -

How to include sources like QByteArray, QtGlobal??

  • Hello everyone,

    I want to ask what I need to do, do make

    #include <QByteArray>
    #include <QtDebug>
    #include <QtGlobal>
    #include <QDateTime>
    #include <QCryptographicHash>


    I get the error: "The source cannot be opened" (I translated this into english)

    I installed QT5.4, and the visual studio addin. Do I need something else?

    Cheers Steven

  • Hi and welcome to DevNet!

    You have to specify the exact include paths to your compiler (the path to e.g. QByteArray.h).
    Search for the files you want to include (like QByteArray.h) on the system where Qt is installed, copy the directory path and add it to your project:
    @INCLUDEPATH += Path\To\Includes@

    If you call the compiler directly, you have to pass the include path, too. When you're using mingw, then it looks like that:
    @g++ myproject.cpp -IPath\To\Includes -o myproject.exe@

    Btw.: You don't need to include QByteArray.h to use it ;-)

Log in to reply