Strange behaviour in qml in switch case statement



  • I found strange behaviour in switch case statement in my qml code.
    @
    onItemClicked: {
    console.log("clicked command " + command)
    switch(command) {
    //...
    case ListsListMenu.EAboutCommand:
    console.log("about command")
    listsListViewRoot.showAboutDialog()
    break;
    case ListsListMenu.EHelpCommand:
    break;
    case ListsListMenu.EExitCommand:
    break;
    default:
    break
    }
    }
    @
    I found that only first line after case statement is executed. To execute all lines for given case value I have to enclose them in braces.
    @
    case ListsListMenu.EAboutCommand:
    {
    console.log("about command")
    listsListViewRoot.showAboutDialog()
    }
    break;
    @

    This is strange, because I would expect that everything is executed until break; is reached.



  • Hi,

    It sounds like you have run into https://bugreports.qt.nokia.com/browse/QTBUG-17012 . This issue should be fixed for QtQuick 2.0.

    Regards,
    Michael



  • Hi,

    Thanks for the info.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.