Qt World Summit: Register Today!

[Solved] Unable to include <QtcpSocket>

  • I a doing something wrong. I am trying to get a mail program up and I am compiling example code. In the code it does an include block shown below. However, it says that it can not find <QTcpSocket>,<QAuthenticator>,<QSslSocket>. However I can see these files in C:\QsSDK\Desktop\Qt\4.7.3\minigq\include\Qt for the .h files and C:\QsSDK\Desktop\Qt\4.7.3\minigq\include\Qt\QtNetwork for the cpp file I think. What include path/options am I missing?

    #include <QString>
    #include <QStringList>
    #include <QObject>
    #include <QTcpSocket>
    #include <QPointer>
    #include <QAuthenticator>
    #include <QSslSocket>

  • Have you added the network module in the *.pro file ?

    @QT += network@

  • I know most of the example state otherwise but you should always use the library prefix when including headers, especially with Mac OS X frameworks and non-qmake projects.
    #include <QtCore/QString>
    In addition - as Rahul Das said - you will have to add the corresponding modules in your project file.

  • This was it. I knew it was something easy. Thanks!


Log in to reply