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

Tomasz Siekierda sierdzio at gmail.com
Tue Jan 3 11:25:02 CET 2012


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:

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,

More information about the Development mailing list