Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtCreator QtQuick QML/JS Editing auto format on save removes pragma value

QtCreator QtQuick QML/JS Editing auto format on save removes pragma value

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
3 Posts 3 Posters 197 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
    Money
    wrote on 18 Dec 2024, 21:49 last edited by
    #1

    I turned on "Enable auto format on save" for QML/JS Editing of QtQuick in QtCreator settings.

    One of my QML files starts with

    pragma ComponentBehavior: Bound
    

    When I save the QML file, it will be reformatted. But the value "Bound" is removed at the same time.

    So, now the first line looks like:

    pragma ComponentBehavior
    

    ... and gives me an error.

    Is this an error with QtCreator or something wrong at my side?

    QtCreator: version: 15.0.0
    Qt 6.8.1 MinGW 64-bit
    Windows 11, up-to-date

    P 1 Reply Last reply 18 Mar 2025, 09:53
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 19 Dec 2024, 19:33 last edited by
      #2

      Hi and welcome to devnet,

      That looks rather like a bug.

      Did you already check the bug report system for something similar ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Money
        18 Dec 2024, 21:49

        I turned on "Enable auto format on save" for QML/JS Editing of QtQuick in QtCreator settings.

        One of my QML files starts with

        pragma ComponentBehavior: Bound
        

        When I save the QML file, it will be reformatted. But the value "Bound" is removed at the same time.

        So, now the first line looks like:

        pragma ComponentBehavior
        

        ... and gives me an error.

        Is this an error with QtCreator or something wrong at my side?

        QtCreator: version: 15.0.0
        Qt 6.8.1 MinGW 64-bit
        Windows 11, up-to-date

        P Offline
        P Offline
        prosenjitjoy
        wrote on 18 Mar 2025, 09:53 last edited by
        #3

        @Money Hi, today i faced exactly the same problem. Thus found your question through a google search. The problem seems to go away if I turn a setting on. Go to Edit->Preferences->Qt Quick->QML/JS Editing tab. Then tick 'Use custom command instead of built-in formatter'. In my case this option is now marked checked along with 'Enable auto format on file save'.
        Now I don't have this weird issue anymore.

        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