Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Strange behaviour in qml in switch case statement
QtWS25 Last Chance

Strange behaviour in qml in switch case statement

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 21.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MichK
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MichK
        wrote on last edited by
        #3

        Hi,

        Thanks for the info.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved