Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting signals to slots with less params allowed in Qt?

Tags:

signals

qt

slot

Is it valid to call

QObject::connect(a, SIGNAL(somesig(someparam)), b, SLOT(someslot()));

without params? It seems to work (no runtime exception thrown) but I can't find a reference in the docs. All I found is that this is possible if someslot has a default parameter. It is valid in this case. But my method someslot has not the same parameter set as default (no parameter here in the example).

So it seems to be possible to wire signals to slots with less parameters?

like image 798
Beachwalker Avatar asked Aug 22 '13 18:08

Beachwalker


1 Answers

Yes, that's fine. There's a short sentence about it in the Signals & Slots documentation:

[...] The signature of a signal must match the signature of the receiving slot. (In fact a slot may have a shorter signature than the signal it receives because it can ignore extra arguments.) [...]

There's even an example like that further down the page where default arguments are explained.

like image 112
Mat Avatar answered Sep 18 '22 13:09

Mat