From 52bac339b6267aa9aaa3e2e0d02c2a62e47f83e4 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 6 Apr 2012 06:57:51 +0000 Subject: Qt is tested more thoroughly, some read bugs are fixed. It also works better with qt principles. You can hook up the readyRead signal to the readObject slot on GatsStream, and connect the GatsStream objectRead signal to your own functions, and you'll be notified whenever a new gats object is read. Cool. --- c++-qt/tests/echo/mainwnd.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 c++-qt/tests/echo/mainwnd.cpp (limited to 'c++-qt/tests/echo/mainwnd.cpp') diff --git a/c++-qt/tests/echo/mainwnd.cpp b/c++-qt/tests/echo/mainwnd.cpp new file mode 100644 index 0000000..4b90421 --- /dev/null +++ b/c++-qt/tests/echo/mainwnd.cpp @@ -0,0 +1,30 @@ +#include "mainwnd.h" + +MainWnd::MainWnd() +{ + pSrv = new QTcpServer( this ); + connect( pSrv, SIGNAL(newConnection()), this, SLOT(newConnection())); + pSrv->listen( QHostAddress::Any, 7317 ); +} + +MainWnd::~MainWnd() +{ +} + +void MainWnd::newConnection() +{ + while( pSrv->hasPendingConnections() ) + { + QTcpSocket *pSock = pSrv->nextPendingConnection(); + Gats::GatsStream *pGats = new Gats::GatsStream( *pSock ); + connect( pSock, SIGNAL(readyRead()), pGats, SLOT(readObject()) ); + connect( pGats, SIGNAL(objectRead( Gats::Object * )), + this, SLOT(objectRead( Gats::Object * ))); + } +} + +void MainWnd::objectRead( Gats::Object *pObj ) +{ + ((Gats::GatsStream *)sender())->writeObject( pObj ); + delete pObj; +} -- cgit v1.2.3