[Solved] Problems including QUdp functionality

Sysprogs forums Forums VisualGDB [Solved] Problems including QUdp functionality

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #6261
    philmacu
    Participant

    Hi,

    I am trying to include UDP functionality in a Qt based GUI project. I am using VS2013 with VisualGDB. In the past I have not had any problems adding in includes for QLabel and other Qt libraries, but I am now! Below is the header and .cpp for a very basic object. VS2013 doessn’t report any intellisense erros, but when I go to build it says it can’t find the QUdpSocket or QHostAddress files. I have checked they are on both the destination machine and in my local cache.

    #pragma once

    #include <QMainWindow>
    #include <QWidget>

    #include <string>
    #include <QUdpSocket>
    #include <QHostAddress>

    using namespace std;

    class QUdpSocket;

    class egdClass : public QWidget
    {
    Q_OBJECT
    public:
    egdClass();
    ~egdClass();
    int send(std::string dataToGo);
    QUdpSocket *udpSocket;
    private:
    int packetNumber;
    QHostAddress destinationIP;
    };

     

    and the .cpp

    #include “egdClass.h”
    egdClass::egdClass()
    {
    udpSocket = new QUdpSocket(this);
    packetNumber = 0;
    destinationIP.setAddress(“192.168.1.11”);
    }

    egdClass::~egdClass()
    {
    delete udpSocket;
    }

    int egdClass::send(std::string dataToGo)
    {
    QByteArray datagram = dataToGo.c_str() + QByteArray::number(packetNumber);
    udpSocket->writeDatagram(datagram.data(), datagram.size(), destinationIP, 45454);
    }

     

    Any ideas why I get this error on build?

    C:\Users\Phil\Documents\sts_dev\embedded_1\embedded_1\.\egdClass.h(7,22): fatal error : QUdpSocket: No such file or directory

     

    #6262
    philmacu
    Participant

    Solved it 🙂

     

    Needed to modify the .pro file to include QT network reference, originally it only referenced the GUI and Core,

     

    QT       += core gui network

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.