Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. connect is driving me batty!
Qt 6.11 is out! See what's new in the release blog

connect is driving me batty!

Scheduled Pinned Locked Moved Solved C++ Gurus
5 Posts 3 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • fcarneyF Offline
    fcarneyF Offline
    fcarney
    wrote on last edited by
    #1

    This should work:

    QWebSocket *socket = new QWebSocket(QString(), QWebSocketProtocol::VersionLatest, this);
    ...
    connect(socket, &QWebSocket::error, [=](QAbstractSocket::SocketError error){
    
    });
    

    Does not want to work. It sees QWebSocket type and function. Socket is a qobject. I don't understand.

    C++ is a perfectly valid school of magic.

    fcarneyF 1 Reply Last reply
    0
    • fcarneyF fcarney

      This should work:

      QWebSocket *socket = new QWebSocket(QString(), QWebSocketProtocol::VersionLatest, this);
      ...
      connect(socket, &QWebSocket::error, [=](QAbstractSocket::SocketError error){
      
      });
      

      Does not want to work. It sees QWebSocket type and function. Socket is a qobject. I don't understand.

      fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      @fcarney Crappola!

      https://doc.qt.io/qt-5/qwebsocket.html#error-1

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      0
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #3
        connect(socket, QOverload<QAbstractSocket::SocketError>::of(&QWebSocket::error), [=](QAbstractSocket::SocketError error){
                
        });
        

        C++ is a perfectly valid school of magic.

        1 Reply Last reply
        4
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          If you're using C++14 and a decent compiler you can shorten that a little to

          connect(socket, qOverload<QAbstractSocket::SocketError>(&QWebSocket::error), [=](QAbstractSocket::SocketError error){    
          });
          

          which still kinda sucks. I hope we get rid of the existing overloads in Qt6. I sure would love to get rid of stuff like currentIndexChanged() overloaded on int and QString.

          1 Reply Last reply
          2
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Chris-Kawa said in connect is driving me batty!:

            I sure would love to get rid of stuff like currentIndexChanged() overloaded on int and QString.

            I failed with my last patch for it :D

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved