QML: StackView and replace
QML: StackView and replace
我不确定是否正确使用StackView
。我有几个QML对象,我展示了它们替换StackView
中的currentItem。这是一个简单的方法,有过渡而不使用两个Loaders
。
类似:
import QtQuick 2.5
import QtQuick.Controls 1.4
StackView {
id: stack
anchors.fill: parent
initialItem: initObj
}
Component {
id: initObj
ModuleHome {}
}
Component {
id: obj1
Module1 {}
}
// ...
stack.push({item: item, replace: true, destroyOnPop: true})
碰巧我在一个页面上有一个错误,我注意到调试控制台的错误信息在我按压对象时重复了很多次。
。第一次:
第二次独有:/MyObject。qml:15: TypeError: Cannot write property of null
:
第三时间:独有:/MyObject。qml:15: TypeError: Cannot write property of null
独有:/MyObject。qml:15: TypeError: Cannot write property of null
独有:/MyObject。qml:15: TypeError: Cannot write property of null
独有:/MyObject。qml:15: TypeError: Cannot write property of null
独有:/MyObject。qml:15: TypeError: Cannot write property of null
我想知道push
方法中的replace
标志是否实际上是pop
(因此销毁)对象和包含的所有对象。
http://doc.qt.io/qt-5/qml-qtquick-controls-stackview.html
在StackView中有三个主要的导航操作:push(), pop()和replace(通过指定参数replace来替换push())。这些对应于经典的堆栈操作,其中"push"将一项添加到堆栈的顶部,"pop"从堆栈中删除顶部的项,而"replace"就像pop后接push,它将堆栈中最顶部的项替换为新项
我想你的问题可能与这个有关:
QML StackView: Item Destroyed on pop
(使用Item代替Component)
- Selenium WebDriver and JavaScript change
- PHP and Javascript functions
- Javascript Return and if/else
- SetTimeout and clearTimeout in Javascript
- lightbox in html 5 and javascript
- TimelineJS and AngularJS
- timeago.js with datatable and PHP
- javascript button ajax and php
- Ajax and Json with Rails
- Combine onload, onresize and onclick
- toFixed and replace dons'这似乎奏效了
- How can I get and replace this in javascript ( jquery?
- 通过 jQuery Find and Replace 将文本 URL 与 标记包装在一起
- Trouble with replace() and § JavaScript
- Regexp javascript and replace
- javascript .replace and jQuery .map
- Find and Replace可在Notepad++中跟踪URL
- jQuery Find and Replace正在挂断浏览器!数据大小太大
- QML: StackView and replace
- Javascript: location.replace and CSS-classes