2017-07-25 96 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