有一個問題,第一個影片有效而第二個影片無效。在第一種情況下,整個矩形都是影片的,這是不希望的,我只需要為標簽設定影片,但是將影片添加到標簽并沒有帶來任何效果。你知道為什么第二個影片沒有影片的問題是什么嗎?
第一的:
import QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
import QtQml.Models 2.12
Rectangle{
property alias text: label.text
clip: true
NumberAnimation on x {
id: animation
from: 100.0
to: -100.0
duration: 500
running: true//label.text.length > 25
loops: Animation.Infinite
}
Label {
anchors.fill : parent
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
id: label
}
}
第二:
import QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
import QtQml.Models 2.12
Rectangle{
property alias text: label.text
clip: true
Label {
anchors.fill : parent
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
id: label
NumberAnimation on x {
id: animation
from: 100.0
to: -100.0
duration: 500
running: true//label.text.length > 25
loops: Animation.Infinite
}
}
}
uj5u.com熱心網友回復:
我在你的第二個影片中發現了兩個問題。
你的 Rectangle 應該有width和height或anchor.fill: parent
您應該洗掉標簽anchor.fill: parent以允許更改x
簽出我的代碼。它現在正在作業:
import QtQuick 2.12
import QtQuick.Controls 2.12
Rectangle{
property alias text: label.text
clip: true
anchors.fill: parent
Label {
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
id: label
Text {
id: name
text: qsTr("text")
color: "black"
}
NumberAnimation on x {
id: animation
from: 100.0
to: -100.0
duration: 500
running: true//label.text.length > 25
loops: Animation.Infinite
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/388672.html
下一篇:視圖的幀在關閉影片之前跳轉,使用自定義UIViewControllerTransitioningDelegate
