qml

Qml: use Text's elide property with textFormat: RichText

心不动则不痛 提交于 2020-01-23 08:19:53
问题 I have an RSS feed with escaped HTML characters that I want to display in a Text component where I trim the excess content with elide: Text.ElideRight and wrapMode: text.WordWrap . While this works very well for plain text, when I use textFormat: Text.RichText the trimming does not work. How can I make the trimming to work or, if this is impossible, encode the HTML easily prior to binding it to the text component? 回答1: Indeed Text doesn't support elide for Text.RichText . There is a bug open

Qt 5.12--Qt QML语法

左心房为你撑大大i 提交于 2020-01-23 03:01:35
Qt 5.12--Qt QML语法 1 简介 2 基本语法 2.1 Import 说明 2.1.1 模块(命名空间)导入 2.1.2 目录导入 2.1.3 JavaScript资源导入 2.1.4 别名("as"规则说明) 2.1.5 非模块命名空间导入 3 QML对象属性 参考 1 简介 QML是用于创建高度动态应用程序的多范式语言。 使用QML,可以声明应用程序构建块(如UI组件),并设置各种属性来定义应用程序行为。 可以通过JavaScript(该语言的子集)进一步编写应用程序行为脚本。 此外,QML大量使用Qt,Qt允许直接从QML应用程序访问类型和其他Qt功能。 2 基本语法 2.1 Import 说明 导入语句允许客户端告诉引擎QML文档中使用了哪些模块,JavaScript资源和组件目录。 文档中可以使用的类型取决于文档导入的模块,资源和目录。 QML定义了 3 种不同的导入类型 2.1.1 模块(命名空间)导入 最常见的导入类型是模块导入。 客户端可以导入QML模块,这些模块将QML对象类型和JavaScript资源注册到给定的名称空间中。 模块导入的通用形式如下: import <ModuleIdentifier> <Version.Number> [as <Qualifier>] example: import QtQuick 2.0

20200116-01 QML Table List 实现 delegate 基于 QT5.14

ε祈祈猫儿з 提交于 2020-01-23 02:33:29
说明 在 QML 表格类实现类时 QWidget 那样的自定义委托(也就是插入自定义控件) 输出函数位于 testsub.cpp/ setValue 中 源码 //file: main.cpp #include <QGuiApplication> #include <QQmlAppliction> #include "testsub.h" #include "testModel.h" Q_DECLARE_METATYPE(TestSub*) //向 QML 声明指针 int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); qmlRegisterType<TestModel>("MyDataModel", 1, 0, "TableModel"); qmlRegisterType<TestSub>(); //声明 TestSub 类型 Qt5.13 及以下版本使用 //qmlRegisterAnonymousType<TestSub>("MyDataModel", 1): //声明 TestSub 类型 Qt5.14 启用 QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc::/main.qml")); return app

Qt 5.12--Qt QML

假如想象 提交于 2020-01-23 00:05:16
Qt 5.12--Qt QML 1 简介 2 QML语法 2.1 基本语法 2.1.1 Import 说明 2.1.1.1 3种不同的导入类型 2.2 QML对象属性 2.3 3 4 知识点 4.1 引用 参考 1 简介 Qt QML模块提供了使用QML语言开发应用程序和库的框架。 它定义并实现了语言和引擎基础结构,并提供了一个API,使应用程序开发人员能够使用自定义类型扩展QML语言并将QML代码与JavaScript和C ++集成在一起。 Qt QML模块同时提供QML API和C ++ API。 Qt Quick模块提供了许多视觉组件,模型视图支持,动画框架,以及用于构建用户界面的更多内容。 2 QML语法 2.1 基本语法 2.1.1 Import 说明 2.1.1.1 3种不同的导入类型 模块(名称空间)导入 目录导入 JavaScript资源导入 导入QML模块,这些模块将QML对象类型和JavaScript资源注册到给定的名称空间中。 一个QML文档可能在文件顶部具有一个或多个导入。 导入可以是以下任意一项: 已注册类型的版本化名称空间(例如,通过插件) 包含类型定义作为QML文档的相对目录 一个JavaScript文件 qml中导入的js文件必须要有别名,别名的命名规则: 以大驼峰的形式命名由js文件名中除了_和impl以外的字母组成 import "jsfile

Dynamically create QML ListElement and content

て烟熏妆下的殇ゞ 提交于 2020-01-22 17:55:47
问题 So I am trying to dynamically create ListElements in a ListModel . This works fine until I try writing some content in the ListElements to be loaded dynamically. I tried making an own file with the ListElement within and the hour as a property, but the model then I got an error saying that ListElements can not be nested. The error for running the code below is: Cannot assign to non-existent property "hour" How can I solve this? Code: import QtQuick 2.0 ListModel { id: listModel Component

QML Profiler fails to connect to server

谁说我不能喝 提交于 2020-01-22 17:46:11
问题 I'm trying to use QML Profiler to find out what is slowing my program down, but when I start it, I get this message: QML Profiler: Connecting to debug server at 127.0.0.1:50540 ... QML Profiler: Resolving host QML Profiler: Establishing network connection ... QML Profiler: Network connection dropped which repeats for a few second, and eventually a popup appears saying: Could not connect to the in-process QML Profiler. Do you want to retry? I have checked Enable QML Debugging and Profiling in

QML Profiler fails to connect to server

℡╲_俬逩灬. 提交于 2020-01-22 17:44:04
问题 I'm trying to use QML Profiler to find out what is slowing my program down, but when I start it, I get this message: QML Profiler: Connecting to debug server at 127.0.0.1:50540 ... QML Profiler: Resolving host QML Profiler: Establishing network connection ... QML Profiler: Network connection dropped which repeats for a few second, and eventually a popup appears saying: Could not connect to the in-process QML Profiler. Do you want to retry? I have checked Enable QML Debugging and Profiling in

Qt 5.12--Qt Quick(Controls )

寵の児 提交于 2020-01-22 05:43:02
Qt 5.12--Qt Quick(Controls ) 1 简介 2 版本号 3 引用 4 语法 4.1 子模块 4.2 基本类型 参考 1 简介 Qt Quick模块是用于编写QML应用程序的标准库。 Qt QML模块提供了QML引擎和语言基础结构,而Qt Quick模块提供了使用QML创建用户界面所需的所有基本类型。 它提供了一个视觉画布,并包括用于创建和动画化视觉组件,接收用户输入,创建数据模型和视图以及延迟对象实例化的类型。它包括视觉类型,交互类型,动画,模型和视图,粒子效果和着色器效果。 Qt Quick模块既提供了QML API(用于提供使用QML语言创建用户界面的QML类型),又提供了C ++ API(用于使用C ++代码扩展QML应用程序)。 一组基于Qt Quick的UI控件也可用于创建用户界面。 Qt Quick Controls 2提供了一组控件,可用于在Qt Quick中构建完整的界面。 该模块在Qt 5.7中引入 。 2 版本号 Qt 5.7中引入了Qt Quick Controls 2.0。 随后的次要Qt发行版将Qt Quick Controls 2模块的导入版本增加1,直到Qt 5.12,其中导入版本与Qt的次要版本匹配。 实验性Qt Labs模块使用导入版本1.0。 3 引用 .qml file: import QtQuick.Controls

Qt Virtual Keyboard Custom Style

谁说胖子不能爱 提交于 2020-01-21 15:44:30
问题 I need to build a custom Style for a Qt VirtualKeyboard on a small screen to maximize its readability. I have built a custom layout into my project, and using the QT_VIRTUALKEYBOARD_LAYOUT_PATH it works great. The problem I am having is that the documentation states that the custom style must be placed in the Qt Directory. I need this style to be portable, however, so storing this newly built style on my local machine, rather than in the project itself, will not be acceptable. Is there any

Qt5 新特性

雨燕双飞 提交于 2020-01-20 20:46:23
Qt 5 已经临近发布,其最大的特点就是模块化。将原来庞大的模块更细分为不同的部分,同时,一个大版本的升级,当然少不了添加、删除各个功能类。文本简单介绍 Qt5 的特性,其具体内容来自 Qt5 官方 Wiki 的介绍 。 前面说过,Qt5 最大的特性在于模块化。这么多的模块,Qt5 统称为 Qt Essentials。下面就来看看这些模块究竟是什么吧!注意,有些模块没有在这里列出,例如 SQL 等。请在 这里 查看完整的 Qt5 模块列表。 Qt Core Qt Core 类似于 Qt4 中的 QtCore 模块,包含了所有非 GUI 的功能。所有其他的 Qt 模块都基于这个模块。与 Qt4 的 QtCore 不同之处在于,Qt Core 还包括了 XML 等 Qt4 中存在的部分。 QStandardPaths QStandardPaths 是 Qt4 的 QDesktopServices 的增强版,其 API 大部分基于 KDE4 的 KStandardDirs 。这个类提供了比 QDesktopServices 更多的功能,例如在某一存储位置搜索给定文件等。 MimeTypes QMimeDatabase 提供了判断给定文件或内存区块的 mimetype 的功能,原理是通过扩展名和(或)内容信息。 MIME 类型数据库由 freedesktop.org 的 shared