I want to create a simple Tcp Communication project but I get some problems and I dont know how to solve that problem. When I try to find solution all people tell add this code (QT += network)on .pro file but in ui projects I dont have any pro file so I dont know the find the solution.

//commu.h

Qt Code:
  1. #ifndef COMMU_H
  2. #define COMMU_H
  3.  
  4. #include <QtWidgets/QMainWindow>
  5. #include "ui_commu.h"
  6. #include <QtNetwork/QTcpSocket>
  7. #include <QObject>
  8. #include <QString>
  9.  
  10. class commu : public QMainWindow
  11. {
  12. Q_OBJECT
  13.  
  14. public:
  15. commu(QWidget *parent = 0);
  16. ~commu();
  17.  
  18. void start(QString address, quint16 port);
  19.  
  20. private:
  21. Ui::commuClass ui;
  22. QTcpSocket client;
  23. public slots:
  24. void startTransfer();
  25. };
  26.  
  27. #endif // COMMU_H
To copy to clipboard, switch view to plain text mode 

//commu.cpp

Qt Code:
  1. #include "commu.h"
  2. #include <QtNetwork/QHostAddress>
  3.  
  4. commu::commu(QWidget *parent)
  5. : QMainWindow(parent)
  6. {
  7. ui.setupUi(this);
  8.  
  9. connect(&client, SIGNAL(connected()),this,SLOT(startTransfer()));
  10. }
  11.  
  12. commu::~commu()
  13. {
  14. client.close();
  15. }
  16.  
  17.  
  18. void commu::start(QString address, quint16 port)
  19. {
  20. QHostAddress addr(address);
  21. client.connectToHost(addr, port);
  22. }
  23.  
  24. void commu::startTransfer()
  25. {
  26. client.write("Hello, world", 13);
  27. }
To copy to clipboard, switch view to plain text mode 

//main.cpp

Qt Code:
  1. #include "commu.h"
  2. #include <QtWidgets/QApplication>
  3. #include <QtCore>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7. QApplication a(argc, argv);
  8. commu w;
  9. w.show();
  10. return a.exec();
  11.  
  12. commu client;
  13. client.start("127.0.0.1", 8888);
  14.  
  15. }
To copy to clipboard, switch view to plain text mode 


I get the errors:

Qt Code:
  1. 1>commu.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QTcpSocket::~QTcpSocket(void)" (__imp_??1QTcpSocket@@UAE@XZ) referenced in function "public: virtual __thiscall commu::~commu(void)" (??1commu@@UAE@XZ)
  2. 1>commu.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QTcpSocket::QTcpSocket(class QObject *)" (__imp_??0QTcpSocket@@QAE@PAVQObject@@@Z) referenced in function "public: __thiscall commu::commu(class QWidget *)" (??0commu@@QAE@PAVQWidget@@@Z)
  3. 1>commu.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QHostAddress::~QHostAddress(void)" (__imp_??1QHostAddress@@QAE@XZ) referenced in function "public: void __thiscall commu::start(class QString,unsigned short)" (?start@commu@@QAEXVQString@@G@Z)
  4. 1>commu.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QHostAddress::QHostAddress(class QString const &)" (__imp_??0QHostAddress@@QAE@ABVQString@@@Z) referenced in function "public: void __thiscall commu::start(class QString,unsigned short)" (?start@commu@@QAEXVQString@@G@Z)
  5. 1>c:\users\sel\documents\visual studio 2010\Projects\commu\Win32\Debug\\commu.exe : fatal error LNK1120: 4 unresolved externals
To copy to clipboard, switch view to plain text mode