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 comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.