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. Simple tcpclient

Simple tcpclient

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 2.6k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    akibsayyed
    wrote on last edited by
    #1

    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;
    }

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

      you must add qtnetwork module in your .pro file

      @
      QT += network
      @

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Alek Śmierciak
        wrote on last edited by
        #3

        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@

        1 Reply Last reply
        0
        • V Offline
          V Offline
          valdemar.pavesi
          wrote on last edited by
          #4

          [[blank-post-content-placeholder]]

          vpavesi

          1 Reply Last reply
          0
          • V Offline
            V Offline
            valdemar.pavesi
            wrote on last edited by
            #5

            [[blank-post-content-placeholder]]

            vpavesi

            1 Reply Last reply
            0

            • Login

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