Search code examples
c++qtslotqt-connection

c++ qt QObject:: connect: No such slot


I have defined my slot like this:

void choixPoints:: prendpixel1(Pixel depart)
{
//...
}

and I want to execute the following sentence:

Pixel depart= picmou->define(); //definition of a pixel, well defined 
connect(chp3, SIGNAL(clicked()), this, SLOT(prendpixel1(Pixel depart)));

However when I execute I obtain:

QObject::connect: No such slot choixPoints::prendpixel1(Pixel depart)

Why doesn't my slot work?


Solution

  • I think the problem is that in your SLOT definition you put a variable name "depart" in, which is not correct. The SLOT and SIGNAL definitions must only have the function name and types. So:

    connect(chp3, SIGNAL(clicked()), this, SLOT(prendpixel1(Pixel)));
    

    BTW I think it is also space sensitive, so SLOT(anotherfn(Pixel, Pixel)) would also be wrong.

    HTH,Ruth