September 20, 2011

MichK MichK
Lab Rat
70 posts

Strange behaviour in qml in switch case statement

 

I found strange behaviour in switch case statement in my qml code.

  1.         onItemClicked: {
  2.             console.log("clicked command " + command)
  3.             switch(command) {
  4.             //...
  5.             case ListsListMenu.EAboutCommand:
  6.                 console.log("about command")
  7.                 listsListViewRoot.showAboutDialog()
  8.             break;
  9.             case ListsListMenu.EHelpCommand:
  10.                 break;
  11.             case ListsListMenu.EExitCommand:
  12.                 break;
  13.             default:
  14.                 break
  15.             }
  16.         }

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.
  1. case ListsListMenu.EAboutCommand:
  2. {
  3.       console.log("about command")
  4.       listsListViewRoot.showAboutDialog()
  5. }
  6. break;

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

2 replies

September 21, 2011

mbrasser mbrasser
Lab Rat
452 posts

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

September 21, 2011

MichK MichK
Lab Rat
70 posts

Hi,

Thanks for the info.

 
  ‹‹ Disable the Flickable      QML/C++ Integration using VS2008 ››

You must log in to post a reply. Not a member yet? Register here!