Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Reformatting QML file gets rid of var in for loop
Forum Update on Monday, May 27th 2025

Reformatting QML file gets rid of var in for loop

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 211 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.
  • B Offline
    B Offline
    bikeaccdnt
    wrote on last edited by bikeaccdnt
    #1

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

    IE:

    for (var i = 0; i < days.length; i++) {
              if (currentDay === days[i]) {
                  logger.info(mediaMsg(media, "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 logger.info line and return true line

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

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

    jsulmJ 1 Reply Last reply
    0
    • B bikeaccdnt

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

      IE:

      for (var i = 0; i < days.length; i++) {
                if (currentDay === days[i]) {
                    logger.info(mediaMsg(media, "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 logger.info line and return true line

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

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

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      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