2017-07-25 133 views
-1

我尝试使用QtNetwork库并在.pro文件中添加了它的所有依赖关系。但是,当我编译我的代码Qt C​​reator的失败,在建设该项目,并声称将网络添加到Qt项目

C1083:包括“与QTcpSocket”:没有这样的文件或目录 - telnet.h:4

我以为加入网络.pro文件就足够了?

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 

回答

4

通常这意味着你忘记重新运行QMAKE

+0

好这解决了这个问题。不知道我必须那样做...谢谢 – betaros

+0

不用担心。 Qt Creator在检测对.pro文件的更改时非常糟糕,所以每次更改该文件时都应该重新运行qmake – IlBeldus