[Qt-interest] Advices on safer SIGNAL macro
Giuseppe D'Angelo
dangelog at gmail.com
Fri Oct 21 00:00:54 CEST 2011
On 19 October 2011 20:47, Johannes Schaub
<schaub.johannes at googlemail.com> wrote:
> For example it would throw a *compile time* error if in the following, you
> wrote "Ptr" instead of "common::Ptr" (as happened for me today). Using the
> original SIGNAL macro, it would do nothing. Alternatively one could check
> the return value of "connect" and throw / abort, but that would be a runtime
> error, only noticed when the "connect" is actually executed:
I totally agree with the need of compile-time checks for connect()
(whenever doable), but I think you just fell into a nice "feature" of
Qt signals/slots, that is, that you must fully qualify signals and
slots arguments or connect() will fail.
(By the way: every connect that fails emits a warning, and you can run
your program under QT_FATAL_WARNINGS=1 to make it crash on the first
warning).
It's never been a requirement that the types of the arguments of the
signal (the slot) had to be available when the connect() call is made.
In fact, the call can happen in a translation unit which knows nothing
about the involved types.
Cheers,
--
Giuseppe D'Angelo
More information about the Qt-interest-old
mailing list