On martedì 17 maggio 2016 17:58:27 CEST Sorokin Vasiliy wrote:
> Hello.
> 
> Example:
> 
> MyButton.qml
> 
> import QtQuick 2.5
> 
> import QtQuick.Controls 1.4
> 
> 
> Button {
> 
>     onClicked: {
> 
>         console.log("inner")
> 
>     }
> 
> }
> 
> 
> mail.qml
> 
> import QtQuick 2.5
> 
> import QtQuick.Window 2.2
> 
> import QtQuick.Controls 1.4
> 
> Window {
> 
>     visible: true
> 
> 
>     MyButton {
> 
>         text: "OK"
> 
>         onClicked: {
> 
>             console.log("outter")
> 
>         }
> 
>     }
> 
> }
> 
> 
> When I click on button I got this output:
> 
> 
> qml: inner
> 
> qml: outter
> 
> And my question is:
> 
> Is this calls order guaranteed?
> 
> --
> Best Regards,
> Vasiliy Sorokin

Hi,
AFAIK you shouldn't rely on any order of execution of slots invoked by a 
signal invokation. 
See http://doc.qt.io/qt-5.6/signalsandslots.html#signals in particular
"""
If several slots are connected to one signal, the slots will be executed one 
after the other, in the order they have been connected, when the signal is 
emitted.
"""
Obviously what you wrote it's just a little example but there're lot of ways 
to solve it:
1) Add a different signal to My Button

Button {
    ...
    signal afterClicked()

   onClicked: {
        // Do something
        afterClicked()
   }
}

2) Hide the inner clicked signal
Item {
    id: root

    signal clicked()

    Button {
         onClicked: { 
               // Do something
               root.clicked() 
         }
    }
}


_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to