1
我需要在SwipeView動畫結束後使用UI中的參數調用C++類方法。QML動畫完成後調用C++函數
main.ui
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
SwipeView {
id: swipeView
anchors.fill: parent
Page1 {
id: page1
}
Page2{
id: page2
}
}
XOR {
id: xor
onXorEnded: {
//swipeView.setCurrentIndex(0)
}
onQChanged: {
page2.bar.value = xor.getq()
}
}
}
Page1Form.ui.qml
Page1Form {
kpButton.onClicked: {
kpDialog.visible = true
}
xorButton.onClicked: {
swipeView.setCurrentIndex(1)
xor.crypt(file_path.text, key_path.text, out_path.text)
}
fpButton.onClicked:{
fpDialog.visible = true
}
FileDialog {
id: fpDialog
onAccepted: {
file_path.text = fpDialog.fileUrl
}
}
FileDialog {
id: kpDialog
onAccepted: {
key_path.text = kpDialog.fileUrl
}
}
}
好像在xorButton.onClicked異或開始滑動視圖的動畫結束之前。它是如何工作現在:Imgur
SwipeView無法訪問其動畫,也無法設置自己的動畫,因此沒有簡單的方法來完成它。這是QML控件中內置的典型特徵,也是我不使用它們的原因。你要麼滿足於它所提供的東西,要麼想要功能性和靈活性,而要自己控制。 – dtech
你的問題是你的'xor.crypt'方法是同步的(它只在所有數據計算完成後才返回),如果你想要你想要的行爲,你應該使它成爲異步的。 – GrecKo