qt - 有没有使用 Lottie 动画的 qt 应用程序的正常示例?
问题描述
有没有使用 Lottie 动画的 qt 应用程序的正常示例?
理想情况下,我想为 Android 和 iOS使用 QML 组件 LottieAnimation ( https://doc.qt.io/qt-5/qml-qt-labs-lottieqt-lottieanimation.html )。
看到一个带有 Lottie 动画的工作示例会很酷,它具有正确的 json 文件,该文件在特定坐标中具有整个指定大小。
我现在做不到:
- 找不到动画 lottie json 文件来使动画在应用程序中工作
- 找不到 lottie 的 json 格式的描述
- 无法将彩票图像放入指定的矩形
main.qml
import QtQuick 2.14
import QtQuick.Window 2.14
import QtQuick.Layouts 1.12
import Qt.labs.lottieqt 1.0
import QtQuick.Controls 2.12
Window {
id: idRoot
width: 360
height: 653
visible: true
title: qsTr("Hello World")
RowLayout {
id: idControls
anchors {
left: parent.left
right: parent.right
}
Button {
text: "start"
onClicked: {
idLottieAnimation.start()
}
}
ColumnLayout {
Layout.preferredWidth: 40
Button {
text: "+"
Layout.fillWidth: true
onClicked: {
//idContent.scale = idContent.scale * 1.1
idLottieAnimation.scale = idLottieAnimation.scale * 1.1
idLottieAnimation.x = 0
idLottieAnimation.y = 0
}
}
Button {
text: "-"
Layout.fillWidth: true
onClicked: {
//idContent.scale = idContent.scale / 1.1
idLottieAnimation.scale = idLottieAnimation.scale / 1.1
idLottieAnimation.x = 0
idLottieAnimation.y = 0
}
}
}
Text {
Layout.fillWidth: true
wrapMode: Text.Wrap
text: "window: " + idRoot.width + "-" + idRoot.height + "\n"
+ "lottie: " + idLottieAnimation.width + "-" + idLottieAnimation.height + "\n"
+ idLottieAnimation.x + "-" + idLottieAnimation.y + "\n"
+ "scale: " + idLottieAnimation.scale
}
}
Flickable {
id: idFlickable
anchors.fill: parent
anchors.topMargin: idControls.height + 10
contentWidth: idContent.width;
contentHeight: idContent.height
interactive: true
clip: true
Rectangle {
id: idContent
width: 1000
height: 1000
border.width: 1
border.color: "gray"
LottieAnimation {
id: idLottieAnimation
width: 200 // ignored
height: 200 // ignored
loops: LottieAnimation.Infinite //2
source: "qrc:/lf30_editor_ms0xldnk.json"
Rectangle {
anchors.fill: parent
anchors.margins: -1
color: "transparent"
border.width: 1
border.color: "red"
}
onStatusChanged: {
console.log("onStatusChanged:", status, source)
if (status === LottieAnimation.Ready) {
// any acvities needed before
// playing starts go here
console.log("gotoAndPlay:", startFrame)
gotoAndPlay(startFrame);
}
}
onFinished: {
console.log("Finished playing")
}
}
}
}
}
解决方案
Android 和 iOS 仅支持 web 播放器处理的一小部分效果,这使得大部分动画非常有问题。请务必查看 Lordicon.com - 他们拥有最多的 Web、iOS 和 Android 支持的动画图标。Useanimations.com 的图标少得多,但大多数也适用于移动项目。
推荐阅读
- vba - application.Documents.Add(filePath) 在 VBA 代码干扰时返回 null
- scrapy - 在scrapy css选择器中我如何得到一个字符串''而不是一个子字符串[]
- r - 任何“大”数据框都会使 R DataTable 包崩溃 - 有解决方案吗?
- sitecore - Sitecore 升级后与 Glass Mapper 的奇怪行为渲染链接
- html - 如何使用 Angular 8 在实际的 routerLink 和内部锚点之间进行选择?
- c# - 是否可以从 Razor 读取子元素的属性?
- php - 如何在 Symfony 服务中注入一组参数?
- php - 在 Laravel 的搜索表单中显示数据库结果的问题
- node.js - 如何在docker-compose(Alpine linux)下打开远程shell到node.js容器
- javascript - 过滤数组内的数据并返回按组过滤的对象