[Development] Possible bug in signals and slots handling in QML.

martin.jones at nokia.com martin.jones at nokia.com
Wed Jan 4 07:32:52 CET 2012


Hi,

1. The capitalization of the first alpha character after the underscore is deliberate.  Signal handlers are defined as being 'on' followed by a capital letter.  Since underscore has no capital, it must be the first non-underscore letter.

2. on__PrivateSignal does work in Qt 5.0.  We won't be changing this in earlier Qt versions.

Br,
Martin.

> -----Original Message-----
> From: development-bounces+martin.jones=nokia.com at qt-project.org
> [mailto:development-bounces+martin.jones=nokia.com at qt-project.org]
> On Behalf Of ext Tomasz Siekierda
> Sent: Tuesday, January 03, 2012 8:25 PM
> To: development at qt-project.org
> Subject: [Development] Possible bug in signals and slots handling in QML.
> 
> Hi,
> 
> in a recent conversation on QtDN, we have identified a possible bug in QML
> (Qt Quick 1, that is. It's possible that the both issues affect
> QtQuick2 too). We have also identified a confusing situation that can be
> easily clarified in QDoc. First, a link to the discussion, then a short recap on
> what is going on. Link:
> http://developer.qt.nokia.com/forums/viewthread/12980/#69773
> 
> 1. Capitalisation of private properties "on" slots.
> Let's consider an example:
>     property int __test: 0
>     on__test: {} // does not work!
>     on__Test: {} // does work
> 
> I think, and it seems others back me here, that this is not exactly intuitive.
> Usually, the first character gets capitalised, but in this case, it's the third
> one. It can stay this way, of course, as it's not a biggie, but it would be nice
> to update the documentation to prevent problems in the future. Do you
> agree?
> 
> 2. Signals and slots.
> Using underscores in signals does work, but no default handler is being
> generated. I'll use Lukas Geyer's example from the thread:
> Item {
>     signal publicSignal
>     signal __privateSignal
> 
>     onPublicSignal: { console.debug('onPublicSignal') }
> 
>     Component.onCompleted: {
>         publicSignal();      // does work
>         __privateSignal();  // does work too
>     }
> 
>     on__PrivateSignal: { console.debug('on_privateSignal') }   // does
> not work, undefined property
>     on__privateSignal: { console.debug('on_privateSignal') }   // does
> not work, undefined property
> }
> 
> Is that an intended behaviour? Or maybe the handlers are being created,
> but using a different naming scheme?
> 
> Best regards, and a happy new year,
> sierdzio
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list