title: create a websocket connection and disconnection routine
body: <p>I am reviewing an example of a websokect client, however I could not execute a routine after the return a.exe ();
  I explain I need to perform other routines, however if I do not place return a.exe (); it does not make the connection and it continues with the code, that would have to do so that this does not happen?</p>
  
  <pre><code>#include &lt;QtCore/QCoreApplication&gt;
  #include "sslechoclient.h"
  
  int main(int argc, char *argv[])
  {
      QCoreApplication a(argc, argv);
  
  for (;;;){
      SslEchoClient client(QUrl(QStringLiteral("wss://localhost:1234")));
  
      Q_UNUSED(client);
  
  //my serial reading application
  
  }
  
      return a.exec();
  }
  </code></pre>
  
  <p>Cpp</p>
  
  <pre><code>#include "sslechoclient.h"
  #include &lt;QtCore/QDebug&gt;
  #include &lt;QtWebSockets/QWebSocket&gt;
  #include &lt;QCoreApplication&gt;
  
  QT_USE_NAMESPACE
  
  SslEchoClient::SslEchoClient(const QUrl &amp;url, QObject *parent) :
      QObject(parent)
  {
      connect(&amp;m_webSocket, &amp;QWebSocket::connected, this, &amp;SslEchoClient::onConnected);
      connect(&amp;m_webSocket, QOverload&lt;const QList&lt;QSslError&gt;&amp;&gt;::of(&amp;QWebSocket::sslErrors),
              this, &amp;SslEchoClient::onSslErrors);
      m_webSocket.open(QUrl(url));
  }
  
  void SslEchoClient::onConnected()
  {
      qDebug() &lt;&lt; "WebSocket connected";
      connect(&amp;m_webSocket, &amp;QWebSocket::textMessageReceived,
              this, &amp;SslEchoClient::onTextMessageReceived);
      m_webSocket.sendTextMessage(QStringLiteral("Hello, world!"));
  }
  
  void SslEchoClient::onTextMessageReceived(QString message)
  {
      qDebug() &lt;&lt; "Message received:" &lt;&lt; message;
      qApp-&gt;quit();
  }
  
  void SslEchoClient::onSslErrors(const QList&lt;QSslError&gt; &amp;errors)
  {
      Q_UNUSED(errors);
  
      // WARNING: Never ignore SSL errors in production code.
      // The proper way to handle self-signed certificates is to add a custom root
      // to the CA store.
  
      m_webSocket.ignoreSslErrors();
  }
  </code></pre>
  
  <p>.h </p>
  
  <pre><code>#ifndef SSLECHOCLIENT_H
  #define SSLECHOCLIENT_H
  
  #include &lt;QtCore/QObject&gt;
  #include &lt;QtWebSockets/QWebSocket&gt;
  #include &lt;QtNetwork/QSslError&gt;
  #include &lt;QtCore/QList&gt;
  #include &lt;QtCore/QString&gt;
  #include &lt;QtCore/QUrl&gt;
  
  QT_FORWARD_DECLARE_CLASS(QWebSocket)
  
  class SslEchoClient : public QObject
  {
      Q_OBJECT
  public:
      explicit SslEchoClient(const QUrl &amp;url, QObject *parent = nullptr);
  
  private Q_SLOTS:
      void onConnected();
      void onTextMessageReceived(QString message);
      void onSslErrors(const QList&lt;QSslError&gt; &amp;errors);
  
  private:
      QWebSocket m_webSocket;
  };
  
  #endif // SSLECHOCLIENT_H
  </code></pre>
  
  <p>I would be very grateful if you can help.</p>