Results 1 to 5 of 5

Thread: QTcpServer and QThread signal/slot problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2008
    Posts
    24
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default QTcpServer and QThread signal/slot problem

    Hi.

    I'm trying to implement tcpserver which runs alongside the GUI program. Here are the classes:

    MainWindow:
    Qt Code:
    1. MainWindow::MainWindow()
    2. {
    3. serverThread = new ServerThread(this);
    4. serverThread->start();
    5. }
    To copy to clipboard, switch view to plain text mode 

    ServerThread(QThread):
    Qt Code:
    1. void ServerThread::run()
    2. {
    3. server = new Server(NULL);
    4. server->listen(QHostAddress::Any, DEF_PORT);
    5. //How to connect MainWindow slots with Server signals?
    6. exec();
    7. }
    To copy to clipboard, switch view to plain text mode 

    Server(QTcpServer):
    Qt Code:
    1. Server::Server(QObject *parent) : QTcpServer(parent)
    2. {
    3. connect(this, SIGNAL(newConnection()), this, SLOT(addConnection()));
    4. }
    To copy to clipboard, switch view to plain text mode 

    How do I connect MainWindow slots with Server signals and am I doing this the right way?
    Last edited by Diph; 28th July 2009 at 14:54. Reason: updated contents

Similar Threads

  1. QTcpServer + QThread
    By Alex Snet in forum Qt Programming
    Replies: 2
    Last Post: 14th April 2009, 21:46
  2. QTcpSocket, QTcpServer problem
    By frido in forum Qt Programming
    Replies: 3
    Last Post: 3rd April 2009, 23:16
  3. QThread and QTcpSocket
    By ^NyAw^ in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2008, 13:06
  4. QThread + QTcpServer
    By Fastman in forum Qt Programming
    Replies: 4
    Last Post: 19th July 2007, 16:19
  5. Replies: 3
    Last Post: 11th May 2006, 00:00

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.