Call a slot in QWidget promoted class
I'm in a class derived from QWidget, within that my class has a slot where asks for a parameter to be passed.
I put a widget in the GUI (Qt Designer) and took a Promote this class.
I tried to give a connect the pushbutton onclick to the slot QWidget (ShowImage(QImage)), but can not find the slot of class I gave Promote.
connect(ui->pushButton, SIGNAL(clicked()), ui->widget, SLOT(ShowImage(QImage)));
QObject::connect: Incompatible sender/receiver arguments
QPushButton::clicked() --> MyWidget::ShowImage(QImage)
When i try:
img.load("D:\\Desert.jpg"); connect(ui->pushButton, SIGNAL(clicked()), ui->widget, SLOT(ShowImage(img)));
Object::connect: No such slot MyWidget::ShowImage(img)
Object::connect: (sender name: 'pushButton')
Object::connect: (receiver name: 'widget')
Signals and slots should have the same arguments. You can not do things like that.
You should connect a SLOT which has no arguments, like this:
connect(ui->pushButton, SIGNAL(clicked()), ui->widget, SLOT(ShowImage()));
and modify ShouwImage method
// Show Image
I put ShowImage as a public method.