PDA

View Full Version : Server-> nextPendingConnection() need some help



kookle
10th November 2012, 08:32
Hi all... I need some help with type casting or any thing which helps me to solve this problem.
I have a QTcpServer, and I connected the
newConnection() signal of it to some slot. As you can see in the code below I used QTcpServer::nextPendingConnection() to get the new connection. but this method returns a QTcpSocket, And instead I need a QSslSocket for the rest of my program. Is it any possible way, for example like static_cast or ... to make the QTcpSocket to a QSslSocket ..!? I know that QSslSocket inherits QTcpSocket


void Server::manageQuery()
{
QTcpServer *myServer = qobject_cast<QTcpServer*>(sender());
QTcpSocket *socket = myServer->nextPendingConnection();

connect(socket,SIGNAL(readyRead()),this,SLOT(proce ssQuery()));
connect(socket,SIGNAL(disconnected()),socket,SLOT( deleteLater()));
}

I mean some code like this


void Server::manageQuery()
{
QTcpServer *myServer = qobject_cast<QTcpServer*>(sender());
QTcpSocket *socket = (QSslSocket)myServer->nextPendingConnection();

connect(socket,SIGNAL(readyRead()),this,SLOT(proce ssQuery()));
connect(socket,SIGNAL(disconnected()),socket,SLOT( deleteLater()));
}

can make the QTcpSocket to QSslSocket? or not