PDA

View Full Version : Avoid QMetaObject::connectSlotsByName warning



qt_developer
19th March 2014, 12:17
Hi,

I've added an optional parameter in the the on_pushButton_clicked() SLOT. The related code:



private slots:
void on_pushButton_clicked(bool isFree = false);




void myClass::on_pushButton_clicked(bool isFree)
{
if (isFree)
{
// Do something
}
else
{
// Do something for not free
}
}


The code works well but I get the next warning:

QMetaObject::connectSlotsByName: No matching signal for on_pushButton_clicked(bool)

Is it possible make some changes to avoid this warning?

Regards.

anda_skoa
19th March 2014, 13:30
The most obvious solution is to avoid connect by name and use real connects.
Has the added benefit of getting an error at compile time when a sender's name is changed instead of the program stopping to work correctly.

I have never understood why anyone would want to use the connect by name feature.

Cheers,