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. [SOLVED] Error - 'QTcpServer::QTcpServer(const QTcpServer&)' is private
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Error - 'QTcpServer::QTcpServer(const QTcpServer&)' is private

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 632 Views 2 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.
  • V Offline
    V Offline
    Veve
    wrote on last edited by Veve
    #1

    I followed this tutorial: http://www.bogotobogo.com/Qt/Qt5_QTcpServer_Multithreaded_Client_Server.php but it didn't worked (telnet didn't connected) so i was thinking it's because tutorial is made for console, as i made a gui, i need to run also the qtcpserver in another thread, so i made a separate QThread that do startServer(), but i get the error: "D:\Qt\5.5\mingw492_32\include\QtNetwork\qtcpserver.h:97: error: 'QTcpServer::QTcpServer(const QTcpServer&)' is private
    Q_DISABLE_COPY(QTcpServer)" on "class MyServer : public QTcpServer"

    If i delete "MyServer server = new MyServer(); server->start();" from the thread that i made to start the server, it compiles without errors. I already did "#include "myserver.h" on the thread, so that's not the problem.

    Edit: Solved, i was using MyServer server= new MyServer(); instead of MyServer server;

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You declared MyServer server = new MyServer() QObject derived class can't be copied, that's the error you are getting.

      You need to use a pointer.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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