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

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

  • Lifetime Qt Champion


    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.

Log in to reply

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