Cast von Klassen

Fehler:‘class QAbstractSocket’ has no member named ‘bind’

if(socket()->socketType()==QAbstractSocket::UdpSocket) {
  (QUdpSocket)(socket())->bind( QHostAddress::Any, port );
}

This way it works:

if(socket()->socketType()==QAbstractSocket::UdpSocket) {
  static_cast<QUdpSocket *>(socket())->bind( QHostAddress::Any, port );
  connect( static_cast<QUdpSocket *>(socket()), SIGNAL( readyRead() ), this, SLOT( readyRead() ) );
}

Leave a Reply

Your email address will not be published. Required fields are marked *