Important: Please read the Qt Code of Conduct -

Reformatting QML file gets rid of var in for loop

  • I have a .qml file that has several for loops.


    for (var i = 0; i < days.length; i++) {
              if (currentDay === days[i]) {
        , "matched day " + currentDay));
                  return true;

    When I select Tools->QML/JS->Reformat File it does this:
    notice that the var i = 0 is missing in the for statement and the semi colon is missing at the end of the line and return true line

        for (; i < days.length; i++) {
          if (currentDay === days[i]) {
  , "matched day " + currentDay))
            return true

    Is there something I am missing ?
    If I reformat then it gives error of undefined variable i.

  • Lifetime Qt Champion

    @bikeaccdnt Looks like a bug. You should check Qt bug tracker and file a bug if it is not already filed.

Log in to reply