how to connect a signal from other class



  • I have my signal SIGNAL(certificatesPeremptionChanged()) ,

    how is implemented in this class configurationmanager.h,

    I want to associate it with the slot markModified (), which is implemented in embeddedcalibbration.cpp Class.

    therefore, i do like
    My header :
    private:
    const ConfigurationManager *_configurationManager;

    My source :
    EmbeddedCalibration::EmbeddedCalibration(QObject *parent,
    bool offlineSensor,
    bool simulatedSensor) :
    Calibration(offlineSensor || simulatedSensor, true, parent),
    EmbeddedProcessAspect(offlineSensor),_configurationManager(NULL),
    _needSave(false)
    {
    connect(this, SIGNAL(modified()), SLOT(markModified()));
    connect(_configurationManager, SIGNAL(certificatesPeremptionChanged()), SLOT(markModified()));
    }
    connect(_configurationManager, SIGNAL(certificatesPeremptionChanged()), SLOT(markModified()));

    And nothing happen.

    I will appreciate you help.

    Thank you !



  • @augus250
    Google for: qt how to connect a signal from other class
    ?
    Lots of hits/examples (e.g. this forum, other forums, stackoverflow...).



  • @JNBarchan I already do it , try to inspire from it but unfortunately, idon't have results.



  • @augus250 said in how to connect a signal from other class:

    @JNBarchan I already do it , try to inspire from it but unfortunately, idon't have results.

    You mean you didn't know what to do from the results you read, or you did not find any results? Because it should return you results OK.

    I will be quiet now, and hope someone else will look at your code and offer some specific advice....



  • @JNBarchan my signal doesn't bring any change I mean .


  • Qt Champions 2016

    @augus250 said in how to connect a signal from other class:

    _configurationManager(NULL),

    It seems you do not create the class?

    please check your connects that they return true.



  • @augus250 when everything fails, please read the user manual :-)

    Seriously, you may want to take a look at the signals & slots documentation, to have a clear understanding about the subject.

    And as a primer about your problem, the key is "Signals and slots are used for communication between objects" so this line:

    connect(this, SIGNAL(modified()), SLOT(markModified()));
    

    is indeed:

    connect(this, SIGNAL(modified()), **OBJECT MISSING!!**, SLOT(markModified()));
    


  • @mrjj Yes exacltly my object was null. thank you.

    So i tried to do this

    EmbeddedCalibration::EmbeddedCalibration(QObject *parent,
    bool offlineSensor,
    bool simulatedSensor,
    ConfigurationManager *configManager) :
    Calibration(offlineSensor || simulatedSensor, true, parent),
    EmbeddedProcessAspect(offlineSensor),
    _needSave(false), _configManager(configManager)

    Here it is my prototype :
    EmbeddedCalibration(QObject *parent=NULL,
    bool offlineSensor=false,
    bool simulatedSensor=false, ConfigurationManager *configManager = NULL);

    {
    connect(this, SIGNAL(modified()), SLOT(markModified()));
    connect(_configManager, SIGNAL(certificatesPeremptionChanged()), SLOT(markModified()));
    DEBUG() << "Configuration manager" <<_configManager;
    }

    my object _configManager point to _configManager which is in this class :

    Lg3Calibration::Lg3Calibration(
    #ifdef DEVICES_I2C
    I2c &i2cBus, quint8 i2cEepromSlaveNumber,
    #else
    const QString &probeName,
    #endif
    const TimeManager *timeManager,
    const MessageManager *messageManager,
    ConfigurationManager *configManager,
    QObject *parent) :
    EmbeddedCalibration(parent, configManager)

    As you see I pass EmbeddedCalibration configManager ,

    I putt the logs and I see that in embedded Calibration _configurationManager is not null but in Lg3Calibration configurationManager is null.

    DEBUG() << "Configuration manager lg3 calibration" <<_configurationManager;
    :Lg3Calibration Configuration manager lg3 calibration MasterclaveConfigurationManager(0x2000af0)
    EmbeddedCalibration::EmbeddedCalibration Configuration manager QObject(0x0)

    Thank you for your help.



  • @Pablo-J.-Rogina

    Thank you for your attention,
    connect(this, SIGNAL(modified()), SLOT(markModified()));

    is indeed:

    connect(this, SIGNAL(modified()), OBJECT MISSING!!, SLOT(markModified()));

    I don't have an object missing at slot , because my slot is in class.
    I used the logs and I see that the connection happens no problem.

    The problem now is about that connection;
    connect(_configManager, SIGNAL(certificatesPeremptionChanged()), SLOT(markModified()));

    I Can't retrieve my object _configManager

    Thank you .


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.