Cannot Open QTcpServer No Such File Or Directory



  • Hello I am trying to write my first application in QT and I seem to be stuck.

    I have added network to the .pro file....

    Exact error is
    "mainwindow.cpp:3: error: C1083: Cannot open include file: 'QTcpServer': No such file or directory"

    //.pro file
    @
    QT += core gui network

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = mytestapp
    TEMPLATE = app

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui
    @

    //mainwindow.h
    @
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>

    namespace Ui {
    class MainWindow;
    }

    class QTcpServer;

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    private:
    Ui::MainWindow *ui;
    QTcpServer *m_server;
    };

    #endif // MAINWINDOW_H

    @

    mainwindow.cpp
    @
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QTcpServer>

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    m_server(new QTcpServer(this))
    {
    ui->setupUi(this);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    @


  • Moderators

    Hi, welcome to devnet.

    You need to re-run qmake for it to pick up the changes in .pro file. Go to Build->Run qmake. Now it should compile.



  • THANK YOU!!!!!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.