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()
newConnection()
To copy to clipboard, switch view to plain text mode
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(processQuery()));
connect(socket,SIGNAL(disconnected()),socket,SLOT(deleteLater()));
}
void Server::manageQuery()
{
QTcpServer *myServer = qobject_cast<QTcpServer*>(sender());
QTcpSocket *socket = myServer->nextPendingConnection();
connect(socket,SIGNAL(readyRead()),this,SLOT(processQuery()));
connect(socket,SIGNAL(disconnected()),socket,SLOT(deleteLater()));
}
To copy to clipboard, switch view to plain text mode
I mean some code like this
void Server::manageQuery()
{
QTcpServer *myServer
= qobject_cast<QTcpServer
*>
(sender
());
[SIZE
=4] QTcpSocket *socket
= (QSslSocket
)myServer
->nextPendingConnection
();
[/SIZE
]
connect(socket,SIGNAL(readyRead()),this,SLOT(processQuery()));
connect(socket,SIGNAL(disconnected()),socket,SLOT(deleteLater()));
}
void Server::manageQuery()
{
QTcpServer *myServer = qobject_cast<QTcpServer*>(sender());
[SIZE=4] QTcpSocket *socket = (QSslSocket)myServer->nextPendingConnection();[/SIZE]
connect(socket,SIGNAL(readyRead()),this,SLOT(processQuery()));
connect(socket,SIGNAL(disconnected()),socket,SLOT(deleteLater()));
}
To copy to clipboard, switch view to plain text mode
can make the QTcpSocket to QSslSocket? or not
Bookmarks