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. In English please... what is "of" for.
Qt 6.11 is out! See what's new in the release blog

In English please... what is "of" for.

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 435 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    I am trying to find out what is "of" for in this connect.
    Mrs Google is of ( no pun intended ) no use.

    connect(server, QOverload<const QString &>::of(&BT_ChatServer::clientConnected),
    this, &BT_Connect::clientConnected);

    I believe this "connect" is between two objects and having a tough time to actually test the "connect" .
    Sure would like to learn how to emulate events / signals. Relying on hardware expected responses is too tiring ....

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by ChrisW67
      #2

      @AnneRanch said in In English please... what is "of" for.:

      I am trying to find out what is "of" for in this connect.

      connect(
        server, QOverload<const QString &>::of(&BT_ChatServer::clientConnected), 
        this, &BT_Connect::clientConnected
      );
      

      QOverload<>::of() is a static function in the Overload helper class that selects one of many overloads for a signal (this case) or slot and returns the correct function pointer. In C++11 code you can use QOverload directly. In C++14 and later you can use the qOverload helper.
      Selecting Overloaded Signals and Slots (Qt5)
      Selecting Overloaded Signals and Slots (Qt6)

      I believe this "connect" is between two objects

      All QObject::connect() calls connect two QObjects.

      and having a tough time to actually test the "connect"

      QObect::connect() returns a value that can be used to test if the act of making the connection was successful. This is especially useful when using the old-style, string-based connect() call, which would fail at run-time and emit a warning, but continue anyway.
      New-style connect() will generally fail at compile time because the arguments are incorrect.

      Sure would like to learn how to emulate events / signals. Relying on hardware expected responses is too tiring ....

      Create a QObject subclass that has a signal with the same signature as the genuine server object and connect that in place of server. Every time the faked server emits clientConnected() the client should react. Qt Test contains a range of classes for unit testing.

      1 Reply Last reply
      2

      • Login

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