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. QMetaObject::Connection, how to test for success
Forum Updated to NodeBB v4.3 + New Features

QMetaObject::Connection, how to test for success

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 595 Views 2 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    I've read in the online documentation that QMetaObject::Connection has an operator bool() which returns true if the connection is valid.

    https://doc.qt.io/qt-5/qmetaobject-connection.html

    Question is how do I access it? I've tried creating a local instance of QMetaObject::Connection cn and assigning it to the return of a QObject::connect.

    How do I perform the test? I see nothing to call.

    Kind Regards,
    Sy

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2
      auto conn = QObject::connect()...
      if (!conn)
      {
        qWarning() << "Connect not successful!";
      }
      

      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
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        It should be something like:

        If (connection) {
            // do what you want 
        }
        

        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
        2
        • SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by
          #4

          Thank you!

          Kind Regards,
          Sy

          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