qml

How to add color on specific words on QML Text

淺唱寂寞╮ 提交于 2020-04-27 06:37:25
问题 Hello i would like to add different color on specific words of a string to be used in QML Text Text { text: "Blue Red Yellow Green" } I know that you can add color to the whole text, but i would like to add specific color on specific words. is this possible? and how is it achieved? 回答1: Text items can display both plain and rich text. For example you can have: Text { text: "<font color=\"#0000FF\">Blue</font> <font color=\"#FF0000\">Red</font>" } 来源: https://stackoverflow.com/questions

QML ListView populate opacity animation

这一生的挚爱 提交于 2020-04-17 22:09:30
问题 I have a ListView and I want to create an fade-in effect for populate ViewTransition. But it not works as expected. It seems that initial opacity of the delegate is 1.0 and so I need to set from property of the animation. But it looked like a flashing. So I need to set initial opacity value of my delegate to 0.0 . Now I have a new problem... when I flick the list, delegates default opacity is 0.0 and so they are invisible. So my question: Can anybody create a perfect fade-in animation for

QML ListView populate opacity animation

半腔热情 提交于 2020-04-17 22:08:27
问题 I have a ListView and I want to create an fade-in effect for populate ViewTransition. But it not works as expected. It seems that initial opacity of the delegate is 1.0 and so I need to set from property of the animation. But it looked like a flashing. So I need to set initial opacity value of my delegate to 0.0 . Now I have a new problem... when I flick the list, delegates default opacity is 0.0 and so they are invisible. So my question: Can anybody create a perfect fade-in animation for

Filter model items in tree view

浪子不回头ぞ 提交于 2020-04-16 05:49:43
问题 I have a model class: class ItemModel : public QAbstractItemModel { Q_OBJECT public: enum ItemRoles { ItemRole = Qt::UserRole + 1, NameRole, IdRole, FilterRole // To be used in filtering }; QVariant data(const QModelIndex &index, int role) const; } Model returns data according to roles: QVariant ItemModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); Item *item = itemFromIndex(index); switch (role) { case ItemRole: return QVariant::fromValue(item);

QQuickPaintedItem鼠标精准拾取(pick/select)研究

独自空忆成欢 提交于 2020-03-27 18:14:31
QT C++在2D图形方面已经做的很完善了,在PC端(Windows、Linux和MaC)上都有很好的表现。 QT中的QML特别适合于移动端应用的开发,QML中的一些基本形状类型并不是一一地与Qt C++相对应,但是通过C++可以来扩展QML。 QQuickPaintedItem继承自QQuickItem,提供了使用QPainter API的方法来扩展QML中的2D图形项。 QQuickPaintedItem没有像QGraphicsItem那样提供shape()方法来获取图形项的具体实际形状,但是其包含contains()方法,我们可以间接地结合鼠标操作点来判断是否包含在实际形状范围内。 废话不多说,直接上测试代码: CustomItem.h 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 #ifndef CUSTOMITEM_H #define CUSTOMITEM_H #include <QQuickPaintedItem> #include <QQuickItem> #include <QMouseEvent> #include <QPainter> class CustomItem : public

How can I assign an ordering number to dynamically created component in qml?

梦想的初衷 提交于 2020-03-25 16:08:52
问题 My code (actually an official example) can draw markers and polylines on the point which I clicked. And I want that every marker has their own Text which represents its order. Text "1" for the first marker, and Text "2" for the second marker, for example. But markerCount(declared in componentCreation.js) for the Text does not increase, so all of the Text of the marker is "1" which is a default. In the code, Rectangle which is MapQuickItem's child represents a marker, and it is dynamically

How can I assign an ordering number to dynamically created component in qml?

耗尽温柔 提交于 2020-03-25 16:05:34
问题 My code (actually an official example) can draw markers and polylines on the point which I clicked. And I want that every marker has their own Text which represents its order. Text "1" for the first marker, and Text "2" for the second marker, for example. But markerCount(declared in componentCreation.js) for the Text does not increase, so all of the Text of the marker is "1" which is a default. In the code, Rectangle which is MapQuickItem's child represents a marker, and it is dynamically

How can I dynamically draw a polygon and make its points/markers movable in QML?

点点圈 提交于 2020-03-25 13:42:23
问题 I have came across a problem where I have to dynamically draw a polygon on QML Map using mouse and make its points movable so that user can change those points location. There is a very nice answer to a similar question which helped me to at least add some points/markers dynamically and connect them through lines but it doesn't allow the markers to be movable. Can somebody please help me in this regard? 回答1: In the following code a marker will be added with the right click and you can drag a

Qt 5.7 > QML

心已入冬 提交于 2020-03-23 16:38:22
本文档翻译自Qt官方文档: http://doc.qt.io/qt-5/qtqml-index.html Qt QML Qt QML模块使用 QML语言 为开发应用与库提供一个框架。它定义并实现了语言与引擎的基础架构,同时,它还提供API,使开发者能够使用自定义类型和集成QML、JavaScript与C++来拓展QML语言。包含为 QML API 与 C++ API 。 注意,当Qt QML模块为QML应用提供语言与基础架构提供支持的同时, Qt Quick 模块也提供了许多 visual Component,模型-视图支持,一个动画框架,以及许多其他用于快速开发用户界面的支持。 关于这部分,参见 QML Applications 的介绍。 开始 使用下面的代码来包含模块类的定义: #include <QtQml> 通过导入QtQML就可以使用其中的QML类型了。方法是:将如下语句添加入你的 .qml 文件头部: import QtQml 2.0 要在项目中使用QtQML,还需在 qmake 的 .pro 文件加入: QT += qml    QML 与 QML类型 Qt QML模块中包含了应用程序必须的QML框架和QML类型,参见 QML帮助文档 。 除了 QML基本类型 外,模块还包含了如下QML对象类型: Component (构件) QtObject (Qt对象)

Swipe to delete in QML

我是研究僧i 提交于 2020-03-22 07:48:55
问题 Is it possible to delete items from a ListView in QML like on webOS, i.e. after swiping the entry there's "cancel" and "delete". I'd like to use Qt 4.7 (so QtQuick 1.1) 回答1: There is no default component in QtQuick that can handle gesture signals. There was a Qt labs project that introduced a GestureArea that may do what you want. It was not pacakged with QtQuick 1.1 and I am unsure as to its current status but feel free to give it a try. http://blog.qt.digia.com/blog/2010/10/05/getting-in