Qt 使用QML淡入整个应用程序
如何在整个应用程序中淡入?我尝试在以下代码中使用Qt 使用QML淡入整个应用程序,qt,qml,Qt,Qml,如何在整个应用程序中淡入?我尝试在以下代码中使用OpacityAnimator: import QtQuick 2.12 import QtQuick.Window 2.12 Window { id: mainWindow visible: true width: 640 height: 480 title: qsTr("Hello World") OpacityAnimator { id: animator
OpacityAnimator
:
import QtQuick 2.12
import QtQuick.Window 2.12
Window {
id: mainWindow
visible: true
width: 640
height: 480
title: qsTr("Hello World")
OpacityAnimator
{
id: animator
target: mainWindow;
from: 0;
to: 1;
duration: 10000
running: false
}
Rectangle
{
x: 0
y: 0
width: 200
height: 200
color: "black"
}
}
但这不起作用。错误消息是:
您可以改为使用:
因为错误指向QQuickItem,但窗口不是。您必须通过以下考试:
OpacityAnimator
{
id:动画师
目标:mainWindow.contentItem//或不透明度{…}上的编号信息
用于语法糖。:)是的,的确!我用你的增强功能更新了我的答案:-)我在Android上使用这个应用程序,我发现,窗口
中的不透明性通常不起作用。我应该更新我的问题吗?一般的问题是,窗口
在Android中不能设置不透明性,但标记的解决方案在Des上有效ktop。
W libFinal.so: qrc:/main.qml:15:9: Unable to assign QQuickWindowQmlImpl to QQuickItem
import QtQuick 2.12
import QtQuick.Window 2.12
Window {
id: mainWindow
visible: true
width: 640
height: 480
title: qsTr("Hello World")
opacity: 0
NumberAnimation on opacity {
from: 0
to: 1
duration: 1000
running: true
}
Rectangle {
x: 0
y: 0
width: 200
height: 200
color: "black"
}
}
OpacityAnimator
{
id: animator
target: mainWindow.contentItem // <---
from: 0
to: 1
duration: 10000
running: true
}