2 qmlscene是什么,有什么用

Reference

qmlscene是什么

  • Qt 5 includes qmlscene, a utility that loads and displays QML documents even before the application is complete.
  • The qmlscene utility is meant to be used for testing your QML applications, and not as a launcher in a production environment. To launch a QML application in a production environment, develop a custom C++ application or bundle the QML file in a module.

使用qmlscene加载qml文件

  • To load a .qml file, run the tool and select the file to be opened, or provide the file path on the command prompt:
    qmlscene myqmlfile.qml

  • 假如我们有一个文件LXWQmlSceneTest.qml,内容如下:

import QtQuick 2.3

  Rectangle {
      id: simpleButton
      color: "grey"
      width: 150; height: 75

      Text {
          id: buttonLabel
          anchors.centerIn: parent
          text: "button label"
      }
  }

我们就可以直接这样查看结果:

# 我电脑上qmlscene的安装路径
cd /Users/gss/Qt5.6.0/5.6/clang_64/bin
./qmlscene /Users/gss/Documents/qttest/lxw_qml_tutorial/LXWQmlSceneTest.qml 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容