logo
 
?

старые слоты

В Qt5 имеется несколько способов связать сигналы и слоты.

В Qt 5 по прежнему осталась возможность использования старого синтаксиса для связи сигнала и слотов old string-based syntax определенные в QObject или любом наследнике класса QObject (включая QWidget).

The old method allows you to connect that slot to a signal that does not have arguments.

But I cannot know with template code if a function has default arguments or not. There was an implementation that falls back to the old method if there are more arguments in the slot than in the signal.

This however is quite inconsistent, since the old method does not perform type-checking or type conversion.

It was removed from the patch that has been merged.

As you might see in the example above, connecting to QAbstract Socket::error is not really beautiful since error has an overload, and taking the address of an overloaded function requires explicit casting, e.g.

a connection that previously was made as follows: Some macro could help (with c11 or typeof extensions) The best thing is probably to recommend not to overload signals or slots … but we have been adding overloads in past minor releases of Qt because taking the address of a function was not a use case we support.

But now this would be impossible without breaking the source compatibility.

Should QMeta Object:: Connection have a disconnect() function?

The other problem is that there is no automatic disconnection for some object in the closure if we use the syntax that take a closure.

One could add a list of object in the disconnection, or a new function like QMeta Object:: Connection::require Function such as QHost Info::lookup Host or QTimer::single Shot or QFile Dialog::open take a QObject receiver and char* slot. If one wants to do callback c way, one should use std::function (or tr1) But we cannot use STL types in our ABI, so a QFunction should be done to copy std::function.