Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Error with signal

Error with signal

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 1.8k 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.
  • N Offline
    N Offline
    nostrora
    wrote on last edited by
    #1

    Hello,

    i want to use the new Qt 5 syntax for Signals & Slots.
    but is compliacted i think.
    Can you help me ?
    This is my problem

    In my class Bot i have a QTcpSocket named m_socket, and i do a connect

    @connect(m_socket, &QTcpSocket::error, this, &Bot::socketError);@

    there is my socketError slot

    @void Bot::socketError(QAbstractSocket::SocketError e)
    {

    }@

    and there is my .h

    @public:
    void socketError(QAbstractSocket::SocketError e);@

    and there my error

    bq. bot\Bot.cpp:14: error: no matching function for call to 'Bot::connect(QTcpSocket*&, <unresolved overloaded function type>, Bot* const, void (Bot::*)(QAbstractSocket::SocketError))'
    connect(m_socket, &QTcpSocket::error, this, &Bot::socketError);

    Can you help me with that ?

    i just want to use this signal http://qt-project.org/doc/qt-5.1/qtnetwork/qabstractsocket.html#error-2

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rahul Das
      wrote on last edited by
      #2

      Yes, looks complicated syntax compared to old, string based.

      I found "this":http://qt-project.org/wiki/New_Signal_Slot_Syntax , useful for me.


      Declaration of (Platform) independence.

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nostrora
        wrote on last edited by
        #3

        I found the answer in this post
        http://qt-project.org/forums/viewthread/24855

        But I do not understand the connect line

        @connect(m_socket, static_cast<void (QTcpSocket::*) (QAbstractSocket::SocketError)>(&QAbstractSocket::error), this, &Bot::socketError);@

        1 Reply Last reply
        0
        • H Offline
          H Offline
          hula
          wrote on last edited by
          #4

          overloaded function type
          QTcpSocket : public QAbstractSocket
          QAbstractSocket:
          public:
          SocketError error() const;
          Q_SIGNALS:
          void error(QAbstractSocket::SocketError);
          so,
          connect(m_socket, static_cast<void (QTcpSocket::*) (QAbstractSocket::SocketError)>(&QAbstractSocket::error), this, &Bot::socketError);

          1 Reply Last reply
          0
          • IamSumitI Offline
            IamSumitI Offline
            IamSumit
            wrote on last edited by
            #5

            hi ,
            You can simply use this as well ...
            (in .h)
            signals:
            void error(QTcpSocket::SocketError SocketError);
            (in .cpp)
            emit error(pSocket->error());//Where you want to emit...

            Be Cute

            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