导入QML文档目录

2023-11-14

Importing QML Document Directories

导入QML文档目录

A local directory of QML files can be imported without any additional setup or configuration. A remote directory of QML files can also be imported, but requires a directory listing qmldir file to exist. A local directory may optionally contain a directory listing qmldir file in order to define the type names which should be provided to clients which import the directory, and to specify JavaScript resources which should be made available to importers.

可以导入QML文件的本地目录,而无需任何其他设置或配置。也可以导入QML文件的远程目录,但需要存在列出qmldir文件的目录。本地目录可以选择性地包含一个列出qmldir文件的目录,以定义应提供给导入目录的客户端的类型名称,并指定应提供给导入者的JavaScript资源。

Local Directory Imports

本地目录导入

Any QML file on the local file system can import a local directory as using an import statement that refers to the directory's absolute or relative file system path, enabling the file to use the object types defined within that directory.

​本地文件系统上的任何QML文件都可以使用引用目录的绝对或相对文件系统路径的import语句导入本地目录,从而使文件能够使用该目录中定义的对象类型。

If the local directory contains a directory listing qmldir file, the types will be made available with the type names specified in the qmldir file; otherwise, they will be made available with type names derived from the filenames of the QML documents. Only filenames beginning with an uppercase letter and ending with ".qml" will be exposed as types if no qmldir file is specified in the directory.

如果本地目录包含一个列出qmldir文件的目录,则这些类型将可用qmldir文件中指定的类型名称;否则,它们将使用从QML文档的文件名派生的类型名。如果目录中未指定qmldir文件,则只有以大写字母开头并以“.qml”结尾的文件名才会作为类型公开。

An Example

一个例子

Consider the following QML project directory structure. Under the top level directory myapp, there are a set of common UI components in a sub-directory named mycomponents, and the main application code in a sub-directory named main, like this:

考虑以下QML项目目录结构。在顶层目录myapp下,在名为mycomponents的子目录中有一组常见的UI组件,在名为main的子目录中有一组主应用程序代码,如下所示:

myapp
    |- mycomponents
        |- CheckBox.qml
        |- DialogBox.qml
        |- Slider.qml
    |- main
        |- application.qml

The main/application.qml file can import the mycomponents directory using the relative path to that directory, allowing it to use the QML object types defined within that directory:

main/application.qml文件可以使用mycomponents目录的相对路径导入该目录,从而使用该目录中定义的qml对象类型:

import "../mycomponents"

DialogBox {
    CheckBox {
        // ...
    }
    Slider {
        // ...
    }
}

The directory may be imported into a qualified local namespace, in which case uses of any types provided in the directory must be qualified:

目录可以导入到合格的本地命名空间中,在这种情况下,目录中提供的任何类型的使用都必须合格:

import "../mycomponents" as MyComponents

MyComponents.DialogBox {
    // ...
}

The ability to import a local directory is convenient for cases such as in-application component sets and application prototyping, although any code that imports such modules must update their relevant import statements if the module directory moves to another location. This can be avoided if QML modules are used instead, as an installed module is imported with a unique identifier string rather than a file system path.

​对于应用程序组件集和应用程序原型设计等情况,导入本地目录的功能很方便,但如果模块目录移动到另一个位置,导入此类模块的任何代码都必须更新其相关的导入语句。如果改用QML模块,这是可以避免的,因为已安装的模块是使用唯一标识符字符串而不是文件系统路径导入的。

Remotely Located Directories

远程目录

A directory of QML files can also be imported from a remote location if the directory contains a directory listing qmldir file.

如果QML文件目录包含列出qmldir文件的目录,也可以从远程位置导入该目录。

For example, if the myapp directory in the previous example was hosted at "http://www.my-example-server.com", and the mycomponents directory contained a qmldir file defined as follows:

例如,如果上一个示例中的myapp目录位于“http://www.my-example-server.com“,mycomponents目录包含一个qmldir文件,定义如下:

CheckBox CheckBox.qml
DialogBox DialogBox.qml
Slider Slider.qml

Then, the directory could be imported using the URL to the remote mycomponents directory:

然后,可以使用URL将目录导入远程mycomponents目录:

import "http://www.my-example-server.com/myapp/mycomponents"

DialogBox {
    CheckBox {
        // ...
    }
    Slider {
        // ...
    }
}

Note that when a file imports a directory over a network, it can only access QML and JavaScript files specified in the qmldir file located in the directory.

请注意,当文件通过网络导入目录时,它只能访问位于该目录中的qmldir文件中指定的QML和JavaScript文件。

Warning: When importing directories from a remote server, developers should always be careful to only load directories from trusted sources to avoid loading malicious code.

警告:当从远程服务器导入目录时,开发人员应始终注意仅加载来自受信任源的目录,以避免加载恶意代码。

Directory Listing qmldir Files

列出qmldir文件的目录

A directory listing qmldir file distinctly different from a module definition qmldir file. A directory listing qmldir file allows a group of QML documents to be quickly and easily shared, but it does not define a type namespace into which the QML object types defined by the documents are registered, nor does it support versioning of those QML object types.

​列出qmldir文件的目录与模块定义qmldir文件明显不同。列出qmldir文件的目录允许快速、轻松地共享一组QML文档,但它不定义一个类型命名空间,将文档定义的QML对象类型注册到该命名空间中,也不支持这些QML对象类型的版本控制。

The syntax of a directory listing qmldir file is as follows:

列出qmldir文件的目录的语法如下:

Command Syntax Description
Object Type Declaration <TypeName> <FileName>

An object type declaration allows a QML document to be exposed with the given <TypeName>.

对象类型声明允许使用给定的<TypeName>公开QML文档。

Example:

例子:

RoundedButton RoundedBtn.qml
Internal Object Type Declaration internal <TypeName> <FileName>

An internal object type declaration allows a QML document to be registered as a type which becomes available only to the other QML documents contained in the directory import. The internal type will not be made available to clients who import the directory.

内部对象类型声明允许将QML文档注册为仅对目录导入中包含的其他QML文档可用的类型。内部类型将不可用于导入目录的客户端。

Example:

例子:

internal HighlightedButton HighlightedBtn.qml
JavaScript Resource Declaration <Identifier> <FileName>

A JavaScript resource declaration allows a JavaScript file to be exposed via the given identifier.

JavaScript资源声明允许通过给定的标识符公开JavaScript文件。

Example:

例子:

MathFunctions mathfuncs.js

A local file system directory may optionally include a qmldir file. This allows the engine to only expose certain QML types to clients who import the directory. Additionally, JavaScript resources in the directory are not exposed to clients unless they are declared in a qmldir file.

本地文件系统目录可以选择性地包括qmldir文件。这允许引擎仅向导入目录的客户端公开某些QML类型。此外,目录中的JavaScript资源不会向客户端公开,除非它们在qmldir文件中声明。

© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

导入QML文档目录 的相关文章

  • Qt - 设置不可编辑的QComboBox的显示文本

    我想将 QComboBox 的文本设置为某些自定义文本 不在 QComboBox 的列表中 而不将此文本添加为 QComboBox 的项目 此行为可以在可编辑的 QComboBox 上实现QComboBox setEditText cons
  • 从 Qt4 中的文本文件中逐字读取

    我想在 Qt4 中逐字读取一个文本文件 说实话我对它很陌生 我想在另一个文件中每行一个字写入 我可以在 C 中做到这一点 没有任何问题 但是当我尝试在 Qt4 中使用 ifstream 和 ofstream 时 我遇到了错误 这是我的 Qt
  • Qt-Qlist 检查包含自定义类

    有没有办法覆盖加载自定义类的 Qt QList 的比较机制 即在 java 中你只需要重写一个比较方法 我有一个带有我的自定义类模型的 QList QList
  • QML 连接:不推荐使用连接中隐式定义的 onFoo 属性

    升级到 Qt 5 15 时收到以下错误消息 QML Connections Implicitly defined onFoo properties in Connections are deprecated Use this syntax
  • 在高 dpi Windows 平台上自动重新缩放应用程序?

    我正在编写一个需要在高 dpi Windows 192dpi 而不是 96dpi 上运行的 Qt 应用程序 不幸的是 Qt 框架尚不支持高 dpi 至少在 Windows 上 因此我的应用程序及其所有元素看起来只有应有尺寸的一半 有没有办法
  • Qt表格小部件,删除行的按钮

    我有一个 QTableWidget 对于所有行 我将一列的 setCellWidget 设置为按钮 我想将此按钮连接到删除该行的函数 我尝试了这段代码 它不起作用 因为如果我只是单击按钮 我不会将当前行设置为按钮的行 ui gt table
  • 静态变量中的 qt tr()

    我在 qt 中的翻译方面遇到问题 我的项目中的所有翻译都工作正常 但有一个翻译位于类的静态变量中 相应部分代码如下 头文件类似于这样 typedef struct int type QString problematicString inf
  • 如何消除 QTableWidget 中的空白?

    How do I get rid of the whitespace in my application 我想摆脱 QTableWidget 中的空白 蓝色箭头 我该怎么做 这是我的应用程序的代码 gridLayout QGridLayou
  • 来自另一个类的 Qt C++ GUI 调用

    我通过 gui 拖放创建了一个按钮和一个文本浏览器 UI 以及单击按钮功能是在 mainwindow cpp 中创建的 有一个 main cpp 但这是无关紧要的 因为在单击开始按钮之前程序不会启动 include mainwindow h
  • 如何从 matlab 调用 Qtproject?

    我在 matlab 中有一个函数可以写入一个 file txt 我在 qt 项目中使用它 So 当我使用 unix 获取要运行的 qt 编译可执行文件时 我有一个 Matlab 文件 但出现错误 代码 unix home matt Desk
  • Qt中正确的线程方式

    我的图像加载非常耗时 图像很大 并且在加载时也完成了一些操作 我不想阻止应用程序 GUI 我的想法是在另一个线程中加载图像 发出图像已加载的信号 然后用该图像重绘视图 我的做法 void Window loadImage ImageLoad
  • 面向 Delphi 开发人员的 Qt

    有人知道为 Delphi C Builder VCL 开发人员解释 Qt 的书籍或教程吗 对于具有该背景的开发人员来说 学习 Qt 的最佳方法是什么 我对如何使用 Qt 完成我知道如何在 Delphi 中完成的事情特别感兴趣 例如 Qt 相
  • 如何在不同的QT线程中创建一个窗口?

    我有一个应用程序 其中每个线程 主线程除外 都需要创建自己的窗口 我尝试创建一个线程然后调用this gt exec in the run功能 然而 在我接到那个电话之前我就收到了一个错误 ASSERT failure in QWidget
  • 在Qt中,如何正确实现委托?

    我遵循模型 视图 控制器范例 我很确定模型和视图是正确的 但我认为我的代表做错了一些事情 一切都 有效 除了第一次单击控件只是 点亮控件 而第二次单击与之交互之外 这是代表通常的实施方式吗 我的实现需要大量的构造和销毁 由scoped pt
  • QFileDialog 作为 TableView 的编辑器:如何获取结果?

    我正在使用一个QFileDialog作为某些专栏的编辑QTableView 这基本上有效 对一些焦点问题取模 请参阅here https stackoverflow com questions 22854242 qfiledialog as
  • 如何重写(重新实现)QFileSystemModel 中的成员函数

    我已经为此苦苦挣扎了一段时间 Qt s QFileSystemModel由于图标获取算法非常糟糕 在获取数百个文件时速度非常慢 我想完全禁用图标 它们被提取到QFileSystemModel data方法不是虚拟的 QFileSystemM
  • 无法将 [未定义] 分配给 QColor

    我正在使用 Qt 5 11 构建 运行代码 代码中有QML风格如下 Button style delegate Component id enabledButtonStyle ButtonStyle padding top 0 paddin
  • MSVC C4100:“应用程序”:未引用的形式参数警告

    使用 MSVC 编译时 以下代码会生成 C4100 警告 这怎么可能 显然引用了 应用程序 class ApplicationInfo public QObject Q OBJECT public static void initializ
  • 在 QtCreator 中调试时如何查看 qDebug 消息

    我正在从 Eclipse CDT 带有 Qt 集成插件 过渡到 QtCreator 2 0 但仍有一件事困扰着我 QtCreator 当我在 QtCreator 中调试时 我在Application output tab直到我停止正在调试的
  • 在另一个中使用 QAbstractListModel

    我在尝试使用 Qt QML 为我的应用程序开发数据模型时遇到问题 我已经用过一个QAbstractListModel能够将海关数据模型从 C 传递到 QML 并且它对于简单模型 例如基于字符串和布尔的模型 来说就像一个魅力 但现在我需要建立

随机推荐

  • python基础知识—集合

    集合 集合与列表 元组类似 可以存储多个数据 但是这些数据是不重复的 具有自动去重功能 集合的格式 变量名 元素1 元素2 元素3 变量 set 可迭代的内容 可迭代内容 gt list str 元组 字典 一 创建集合 1 set1 Tr
  • Win10和Jetson Nano环境下安装Mediapipe-python

    最近因学习需要用到google的mediapipe包进行手部识别 效果不错便想将其移植到jetson nano的ubuntu系统上 坑不少 在这里记录一下过程 步骤 一 Windows10的安装方法 二 Jetson Nano下的安装方法
  • Tomcat无法自动解压缩webapps下的war包

    Tomcat无法自动解压缩webapps下的war包 1 正常描述 把打好的war包放入tomcat gt webapps中 启动tomcat即可自动解压缩war包 然后即可访问 2 问题描述 启动tomcat 可以访问localhost
  • JavaScript引用数据类型之基本包装类型Boolean、Number、String

    JavaScript引用数据类型之基本包装类型 1 Boolean var falseObj new Boolean false 创建Boolean对象 var falseValue false console log typeof fal
  • 【MySQL】sql_mode 模式

    目录 前言 查看 sql mode 方式 查看当前会话的 sql mode 查看全局的 sql mode sql mode 配置属性 ONLY FULL GROUP BY STRICT TRANS TABLES STRICT ALL TAB
  • 一个中年程序员的10年测试人生,进阶测试专家必备5项技能!

    测试架构师成长线路图 第一步 成为互联网时代合格的测试工程师 如果你是入行不满3年的测试工程师 一定对此有迫切需求 此时 你必须迅速掌握被测软件的业务功能与内部架构 并在此基础上运用各种测试方法 尽可能多地发现潜在缺陷 并能够在已知缺陷的基
  • 无符号数 有符号数 与 补码

    无符号数 有符号数 与 补码 本文是深入理解计算机系统这本书里面关于补码有符号数无符号数章节的一个摘要和读书报告 我个人认为这本书关于这一段的表述 要比绝大多数网上的博客甚至是国内教材要深入浅出的多 同时由于markdown的文档表示公式很
  • vue中的动态路由怎么配置

    如何定义动态路由 如何获取传过来的动态参数 一 param方式 配置路由格式 router id 传递的方式 在path后面跟上对应的值 传递后形成的路径 router 123 1 定义路由 在APp vue中
  • 2.2.1 数据结构——矩阵结构、数组结构与数据框

    创建矩阵的函数名为 matrix 其基本语法格式为 matrix data NA nrow 1 ncol 1 byrow TRUE 其中data表示矩阵的元素 nrow和ncol分别表示了矩阵的行数和列数 byrow TRUE表示按行填充
  • Java:Spring、Java、MyBatis常用注解

    Spring 给容器IOC中注入组件 控制层 Controller 业务层 Service 数据访问层 Repository 通用 Component 泛指各种组件 Controller Service Repository都可以称为 Co
  • 第2章 核心技术概览

    运用之妙夺造化 存乎一心胜天工 有人可能会遇到这样的问题 跨境商贸合作中签订的合同 怎么确保对方能严格遵守和及时执行 酒店宣称刚打捞上来的三文鱼 怎么追踪捕捞和运输过程中的时间和卫生 现代数字世界里 怎么证明你是谁 怎么证明某个资产属于你
  • 基于直方图优化的图像增强技术(MATLAB实现)

    前言 直方图均衡是一种图像增强的常用手段 但全局直方均衡经常会给图像带来失真等问题 为了处理相关问题 本文采取了全局直方均衡 局部直方均衡和Retinex算法来对图像进行处理 主函数 img imread img tif In1 Remov
  • 大数加法(C++实现)

    最常规的大数加法 两个数都是非负的整数 思路 用字符串的方式去存储我们需要计算的数 但是要注意的一点就是我们是倒过来存储这个大数的 比如 123456789 我们存储的时候是存成 987654321 为什么要这么干 我觉得是为了便于后面我们
  • C++ :websocket 通讯下的五种 I/O 模型

    目录 I O 多路复用 一种同步 I O 模型 非阻塞与阻塞 select poll epoll 起因 改善 select 与 poll 的差别 I O 模型 阻塞 I O 模型 非阻塞 I O 模型 I O 多路复用模型 信号驱动 I O
  • php curl 返回文件头,php curl请求信息和返回信息设置代码实例,特别是在请求过程中存在重定向的时候获取请求返回头信息...

    在用curl抓取网页内容的时候 经常要知道 网页返回的请求头信息 和请求的相关信息 特别是在请求过程中存在重定向的时候获取请求返回头信息对分析请求内容很有帮助 下面就是一个请求中存在重定向的例子 我们的目的是要获取最终实际请求的url地址
  • linux服务器做游戏服务器配置,详解Linux中搭建常用服务器

    1 搭建telnet服务器 2 搭建DHCP服务器 3 搭建 服务器 4 搭建sendmail服务器 5 搭建FTP服务器 6 搭建web服务器 安装 apache tomcat 7 搭建samba服务器 一 搭建telnet服务器 1 查
  • Sorry, The number you dialed is power off.

    对不起 您所拨打的电话正在通话中 请稍后再拨 Sorry The subscriber you dialed is busy now please redial later 您好 您所拨打的号码是空号 请核对后再拨 Sorry The nu
  • RestTemplate使用HttpClient连接池

    文章目录 RestTemplate使用HttpClient连接池 ClientHttpRequestFactory SimpleClientHttpRequestFactory SimpleClientHttpRequestFactory
  • 基于聚类分析和协同过滤算法的营养膳食分析系统的设计与实现

    1 简介 今天向大家介绍一个帮助往届学生完成的毕业设计项目 基于聚类分析和协同过滤算法的营养膳食分析系统的设计与实现 1 协同过滤的算法思想 1 1 基于内容的推荐中不足之处 基于内容的推荐方法用户易于理解 简单有效 但是它的缺点也十分明显
  • 导入QML文档目录

    Importing QML Document Directories 导入QML文档目录 A local directory of QML files can be imported without any additional setup