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. Can I run .qml files in CommandPrompt or PowerShell?
Forum Updated to NodeBB v4.3 + New Features

Can I run .qml files in CommandPrompt or PowerShell?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 4 Posters 551 Views 1 Watching
  • 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.
  • qazaq408Q Offline
    qazaq408Q Offline
    qazaq408
    wrote on last edited by
    #1

    Forgive me ,i make a serious mistake.....it's .qml not .xml..

    When i write a python,i can run this file(.py) by some IDE like "PY Charm",but i also can execute file(.py) in CommandPrompt or PowerShell like this

    python E:/HelloWorld.py
    

    So,if i write a QML file,like "E:/HelloQML.qml"

    import QtQuick
    
    Rectangle{
        width: 200
        height: 50
    
        Text{
            anchors.centerIn: parent
            text:qsTr("Hello QML")
        }
    }
    

    Can I execute "E:/HelloQML.qml" by CommandPrompt or PowerShell like

    xxx E:/HelloQML.qml
    
    sierdzioS JonBJ ndiasN 3 Replies Last reply
    0
    • qazaq408Q qazaq408

      Forgive me ,i make a serious mistake.....it's .qml not .xml..

      When i write a python,i can run this file(.py) by some IDE like "PY Charm",but i also can execute file(.py) in CommandPrompt or PowerShell like this

      python E:/HelloWorld.py
      

      So,if i write a QML file,like "E:/HelloQML.qml"

      import QtQuick
      
      Rectangle{
          width: 200
          height: 50
      
          Text{
              anchors.centerIn: parent
              text:qsTr("Hello QML")
          }
      }
      

      Can I execute "E:/HelloQML.qml" by CommandPrompt or PowerShell like

      xxx E:/HelloQML.qml
      
      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @qazaq408 yes, if you have Qt installation in $PATH, you can run any QML file with:

      qml E:/HelloWorld.qml
      

      (Z(:^

      JonBJ 1 Reply Last reply
      1
      • qazaq408Q qazaq408

        Forgive me ,i make a serious mistake.....it's .qml not .xml..

        When i write a python,i can run this file(.py) by some IDE like "PY Charm",but i also can execute file(.py) in CommandPrompt or PowerShell like this

        python E:/HelloWorld.py
        

        So,if i write a QML file,like "E:/HelloQML.qml"

        import QtQuick
        
        Rectangle{
            width: 200
            height: 50
        
            Text{
                anchors.centerIn: parent
                text:qsTr("Hello QML")
            }
        }
        

        Can I execute "E:/HelloQML.qml" by CommandPrompt or PowerShell like

        xxx E:/HelloQML.qml
        
        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @qazaq408
        Start by reading The Whole Shebang - Running QML Files Directly. It's 10 years old, but often Qt stuff remains the same!

        It looks like there should be an executable program qml.exe under Windows --- assuming it exists for that OS. However in any case note the author states

        The usefulness of this tool is somewhat limited, because it only works for self-contained QML files and most real-world applications have some C++ code. However, it can be useful for applications such as tests and small demo programs. You might want to consider using it for small applications that you would have normally written as a shell script, but with QML (and JavaScript) can be done in a more portable way, as well as supporting a graphical user interface.

        1 Reply Last reply
        1
        • qazaq408Q qazaq408 has marked this topic as solved on
        • sierdzioS sierdzio

          @qazaq408 yes, if you have Qt installation in $PATH, you can run any QML file with:

          qml E:/HelloWorld.qml
          
          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @sierdzio
          My post above was made before I saw yours. Does that author's admonition about the limited functionality this way still apply, so that the OP knows?

          sierdzioS 1 Reply Last reply
          0
          • JonBJ JonB

            @sierdzio
            My post above was made before I saw yours. Does that author's admonition about the limited functionality this way still apply, so that the OP knows?

            sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            @JonB it does, yes. That tool won't help with QML files which expect some C++ backend.

            (Z(:^

            1 Reply Last reply
            1
            • qazaq408Q qazaq408

              Forgive me ,i make a serious mistake.....it's .qml not .xml..

              When i write a python,i can run this file(.py) by some IDE like "PY Charm",but i also can execute file(.py) in CommandPrompt or PowerShell like this

              python E:/HelloWorld.py
              

              So,if i write a QML file,like "E:/HelloQML.qml"

              import QtQuick
              
              Rectangle{
                  width: 200
                  height: 50
              
                  Text{
                      anchors.centerIn: parent
                      text:qsTr("Hello QML")
                  }
              }
              

              Can I execute "E:/HelloQML.qml" by CommandPrompt or PowerShell like

              xxx E:/HelloQML.qml
              
              ndiasN Offline
              ndiasN Offline
              ndias
              wrote on last edited by
              #6

              @qazaq408 - Use can use qmlscene.exe (or qmlviewer.exe) for QML preview:

              C:\Qt\6.1.2\msvc2019_64\bin\qmlscene.exe myfile.qml
              
              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