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 *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>