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]Bridging Signal - Slot connection
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Bridging Signal - Slot connection

Scheduled Pinned Locked Moved General and Desktop
signal & slot
2 Posts 1 Posters 500 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.
  • T Offline
    T Offline
    ttuna
    wrote on last edited by ttuna
    #1

    I'm trying to bride a signal - slot connection over a 3rd object.
    Therefor i have implemented a connector class, which uses an id to identify the corresponding participants which registered a signal or slot method:

    class Participant : public QObject
    {
        Q_OBJECT
    public:
        explicit Participant(QObject *in_object, QMetaMethod *in_method, QObject *parent = 0) : QObject(parent),
            m_p_object(in_object), m_p_method(in_method)
        {
        }
    
        QObject *object() { return m_p_object; }
        QMetaMethod *method() { return m_p_method; }
    
    private:
        QObject *m_p_object;
        QMetaMethod *m_p_method;
    };
    
    bool CheckConnection(int in_type)
        {
            Participant *sender = 0, *receiver = 0;
    
            if (m_signal_bridge_map.contains(in_type))
            {
                sender = m_signal_bridge_map.value(in_type);
                if (sender == 0) return false;
                if (sender->object() == 0) return false;
                if (sender->method()->isValid() == false) return false;
                qDebug() << "IConnector::CheckConnection - Sender found ...";
            }
    
            if (m_remote_slot_map.contains(in_type))
            {
                receiver = m_remote_slot_map.value(in_type);
                if (receiver == 0) return false;
                if (receiver->object() == 0) return false;
                if (receiver->method()->isValid() == false) return false;
                qDebug() << "IConnector::CheckConnection - Receiver found ...";
            }
    
            if (sender == 0 || receiver == 0) return false;
    
            qDebug() << "IConnector::CheckConnection - connecting" << sender->method()->name() << receiver->method()->name();
            return QObject::connect(sender->object(), sender->method()->name(), receiver->object(), receiver->method()->name());
        }
    

    When a sender-receiver pair is found, the sender->method()->name() call runs into ASSERT:
    Imgur

    Any idea why this wouldn't work?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      ttuna
      wrote on last edited by ttuna
      #2

      Found the error.
      Stored the pointer of a local QMetaMethod object ... * blush *

      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