Simple tcpclient
-
Respected list
I am bit new to qt. so please help me and correct some of my mistakes.I am trying to create simple tcp client but I am unable to do so. below is my code. when i try to compile it gives me error
"/opt/QT Projects/test/dialog.cpp:-1: error: undefined reference to `QTcpSocket::QTcpSocket(QObject*)'"please tell me whats wrong?
#include "dialog.h"
#include "ui_dialog.h"
#include <QtNetwork/QTcpSocket>
#include <QtNetwork/QTcpServer>
#include<QtNetwork/QNetworkSession>Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog),networkSession(0){
ui->setupUi(this);
QTcpSocket *tcpSocket1=new QTcpSocket (this);
}Dialog::~Dialog()
{
delete ui;
} -
Hello and welcome,
"QTcpServer":http://qt-project.org/doc/qt-5.0/qtnetwork/qtcpsocket.html (and "QNetworkSession":http://qt-project.org/doc/qt-5.0/qtnetwork/qnetworksession.html) classes are held in a "QtNetwork":http://qt-project.org/doc/qt-5.0/qtnetwork/qtnetwork-module.html module. Did you add it to your project .pro file to link against it when compiling?
To "link against QtNetwork":http://qt-project.org/doc/qt-5.0/qtnetwork/qtnetwork-module.html#details, add this line:
@QT += network@ -
[[blank-post-content-placeholder]]
-
[[blank-post-content-placeholder]]