I have 2 classes. Class A and Class B. I am emitting a signal from class A which I want the B to recieve.
I am doing it following way
In Listener File
Header File:
Class Listener:public DDSDataReaderListener
{
//Some code
public:
A m_objectSendData;
}
Implementation File:
void Listener::ondataavailable(DDSDataReader *reader)
{
m_objSendData.GetDDSData();
}
In Class A
Header File:
Class A:public QObject
{
Q_OBJECT
public:
void GetDDSData();
signals:
void Signal_Data();
}
.cpp File
A::A(QWidget *parent):QObject(parent)
{
}
void A::GetDDSData()
{
emit Signal_Data();
}
In Class B
Header File:
Class B:public QObject
{
Q_Object
public:
A objGetData;
public slots:
void getData();
}
Implementation File:
B::B(QWidget *parent):QObject(parent)
{
//Some part of code
connect(&objGetData,SIGNAL(Signal_Data()),this,SLOT(getData());
}
void B::getData()
{
//Watever is to be updated
}
I tried debugging. It is going till emit part correctly. However it is not reaching the slot. Can someone please help me with this. Thank You.
Object::connect: No such slot B::SlotB()
when you run your application? – Hekking)
before;
in yourconnect
statement, but that obviously isn't missing in your actual code. – Hekkingconnect
returns. If it istrue
then connection was successful and you just don't emit signal. If it returnsfalse
then check answer that @Merlin069 has gave you. – SuperficiesobjectA
variable and your emitting object is just destroyed before it can emit any signal (objectA
is local variable created on stack not on heap). – Superficies