betaros
betaros

Reputation: 602

Add network to Qt Project

I try to use the QtNetwork library and added all dependencies for it in the .pro file. But when I compile my code Qt Creator fails in building the project and claims

C1083: Include "QTcpSocket": No such file or directory - telnet.h:4

I thought adding network to the .pro file would be enough?

networkmonitor.pro

#-------------------------------------------------
#
# Project created by QtCreator 2017-07-24T13:18:19
#
#-------------------------------------------------

QT += core gui network charts

# greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = networkmonitor
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0


SOURCES += \
        main.cpp \
        mainwindow.cpp \
        telnet.cpp

HEADERS += \
        mainwindow.h \
        telnet.h

FORMS += \
        mainwindow.ui

telnet.h

#ifndef TELNET_H
#define TELNET_H

#include <QTcpSocket>
#include <QTcpServer>
#include <QDebug>

class Telnet
{
public:
    Telnet();

    void sendValues(QString _ip, int _port, QString _message);

private:
    QTcpSocket *socket;
};

#endif // TELNET_H

Upvotes: 1

Views: 1821

Answers (1)

IlBeldus
IlBeldus

Reputation: 1040

Normally this means you just forgot to re-run qmake

Upvotes: 5

Related Questions