Signals and Slots between two classes
-
Can you use the new connection syntax?
QObject::connect(&t, SIGNAL(valueChanged(int)),&w, SLOT(setValue(int)));should becomeQObject::connect(&t,&Test::valueChanged,&w,&Widget::setValue);@VRonin no change. signals are not recieved in slots.
-
@ktrsathish said in Singals and Slots between two classes:
Form::Form(QWidget *parent) :
QWidget(parent),
ui(new Ui::Form)
{
ui->setupUi(this);
value = 0;
Test obj;
}What should 'Test obj' do here?
void Form::on_button_clicked()
{
value = 1;
obj.EnableImage(value);
}This is not the object you're doing your connect on.
-
@ktrsathish said in Singals and Slots between two classes:
Form::Form(QWidget *parent) :
QWidget(parent),
ui(new Ui::Form)
{
ui->setupUi(this);
value = 0;
Test obj;
}What should 'Test obj' do here?
void Form::on_button_clicked()
{
value = 1;
obj.EnableImage(value);
}This is not the object you're doing your connect on.
@Christian-Ehrlicher My actual implementaion shall follow the above architecture. so I have written the sample code to work first.
-
@Christian-Ehrlicher My actual implementaion shall follow the above architecture. so I have written the sample code to work first.
@ktrsathish
Hi
Could you zip sample and upload via
https://www.justbeamit.com/( single use :( )
any other dropbox, Google drive, etc that can give a link
with no registration required to get it.Code looks ok, but its easy to miss stuff due to all the scrolling.
-
@ktrsathish
Hi
Could you zip sample and upload via
https://www.justbeamit.com/( single use :( )
any other dropbox, Google drive, etc that can give a link
with no registration required to get it.Code looks ok, but its easy to miss stuff due to all the scrolling.
@mrjj https://drive.google.com/file/d/1d0Cc86uItT6F-ZzpbWtreATYICApRG1U/view?ts=5bd73a93
Please check the code and let me know the details. -
@mrjj https://drive.google.com/file/d/1d0Cc86uItT6F-ZzpbWtreATYICApRG1U/view?ts=5bd73a93
Please check the code and let me know the details.@ktrsathish
super !
but it asks permissions.
Can you remove that ? -
@ktrsathish
super !
but it asks permissions.
Can you remove that ? -
@ktrsathish
Hi
In class Form, you have
private:
..
Test obj;and you use that to emit
void Form::on_ABS_ON_clicked()
{
value = 1;
obj.EnableImage(value);
}BUT
the one you hook up in main is another test instance
and its not used to emit the signal.Test t; QObject::connect(&t, &Test::ValueChanged, &w, &Widget::setValue); t is not the one u use to emit signal.So that is why all looks fine but nothing happens.
The actual emitter object is not connected up.So it was as mr. @Christian-Ehrlicher said / suggested
-
@ktrsathish
Hi
In class Form, you have
private:
..
Test obj;and you use that to emit
void Form::on_ABS_ON_clicked()
{
value = 1;
obj.EnableImage(value);
}BUT
the one you hook up in main is another test instance
and its not used to emit the signal.Test t; QObject::connect(&t, &Test::ValueChanged, &w, &Widget::setValue); t is not the one u use to emit signal.So that is why all looks fine but nothing happens.
The actual emitter object is not connected up.So it was as mr. @Christian-Ehrlicher said / suggested
@mrjj said in Signals and Slots between two classes:
Test t;
QObject::connect(&t, &Test::ValueChanged, &w, &Widget::setValue);Thanks. It is solved.