Qt 4.6 behaves differently when "overloading" signals

Thiago Macieira thiago at kde.org
Sat Nov 7 18:19:22 GMT 2009


Em Sábado 7. Novembro 2009, às 18.26.48, Dario Freddi escreveu:
> On Saturday 07 November 2009 18:19:44 you wrote:
> > That warning and behaviour is about 5 or six years old. I asked thiago
> >  about it some weeks before. You only see it now because it only appears
> > in qt developer builds which we only started to use when switching to the
> > qt git repo.
> >
> > So i think the ... it worked with qt <4.6 may be unlikely. Are you really
> > sure?
> 
> Sure, otherwise for example the k3bsetup and some other polkit-qt
>  applications wouldn't work as expected with qt 4.5.

The warning is correct.

Overriding signals is an extremely bad idea. Since signals aren't virtual, the 
code in the base class that emits the signal will emit the lower-ID signal. 
However, the connect() call searches from the most derived class towards 
QObject -- that means you connect to the most-derived class's signal.

In other words, the signal is emitted, but it's never caught.

DO NOT override signals.

Also, Michael is right: that warning is extremely old. It was added for Qt 
4.0.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20091107/35364374/attachment.sig>


More information about the kde-core-devel mailing list