2017-07-25 4 views
-1

J'essaie d'utiliser la bibliothèque QtNetwork et j'ai ajouté toutes les dépendances dans le fichier .pro. Mais quand je compile mon code Qt Creator échoue dans la construction du projet et affirmeAjouter un réseau au projet Qt

C1083: Inclure "QTcpSocket": Aucun fichier ou répertoire - telnet.h: 4

Je pensais que l'ajout de réseau le fichier .pro serait suffisant?

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 

Répondre

4

Normalement, cela signifie que vous avez juste oublié de relancer qmake

+0

Bon qui a résolu le problème. Je ne savais pas que je devais le faire ... Merci – betaros

+0

Pas de soucis. Qt Creator est effrayant lorsqu'il détecte les changements apportés aux fichiers .pro. Chaque fois que vous modifiez ce fichier, vous devez toujours relancer qmake. – IlBeldus