Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cannot Open QTcpServer No Such File Or Directory
Qt 6.11 is out! See what's new in the release blog

Cannot Open QTcpServer No Such File Or Directory

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    EverydayDiesel
    wrote on last edited by
    #1

    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;
    }

    @

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • E Offline
        E Offline
        EverydayDiesel
        wrote on last edited by
        #3

        THANK YOU!!!!!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved