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. [SOLVED]I need explanation about connect()
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]I need explanation about connect()

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.0k 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.
  • U Offline
    U Offline
    unixmania
    wrote on last edited by
    #1

    Signal and slot mechanism is heart of qt.So i want to learn it thoroughly.There are somethings that preoccupies me. QObject::Connect() has five different form.One of them takes 3 arguments.Qt documentation(5.1.0) says about it that
    @
    QMetaObject::Connection QObject::connect(const QObject * sender, const char * signal, const char * method, Qt::ConnectionType type = Qt::AutoConnection) const
    This function overloads connect().

    Connects signal from the sender object to this object's method.

    Equivalent to connect(sender, signal, this, method, type).

    Every connection you make emits a signal, so duplicate connections emit two signals. You can break a connection using disconnect().

    Note: This function is thread-safe.

    See also disconnect().
    @
    About "Equivalent to connect(sender, signal, this, method, type)." above:
    1-Does class which pointing by *this have to be a subclass of QObject?
    2-Does method had to be declared as custom slot?(in case of it is not member any QObject subclass)
    3-Do I have to use SLOT macro such SLOT ( method ( args ) ) ?
    4-Do I have to use Q_OBJECT macro in header?

    All questions above about qt5. Thanks.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi

      1. No, you can declare slots as public, protected or private.
      2. Using this form of connect, yes
      3. Yes you have to

      You can read more about it in this "chapter":http://qt-project.org/doc/qt-5.0/qtcore/signalsandslots.html

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • U Offline
        U Offline
        unixmania
        wrote on last edited by
        #3

        Thank you again.Answers are
        1-Yes
        2-Yes
        3-Yes
        4-Yes

        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