다소 복잡한 시나리오를 가지고 있는데, 다소 복잡한 대리자와 눈에 보이는 영역을 초과 할만큼 충분한 항목이 포함 된 서브 윈도우를 실행하면 전체 서브 창이 즉시 닫힙니다. 쏘다.Subwindow의 ListView가 즉각 닫기 또는 스크롤하는 동안
델리게이트의 복잡성을 줄이면 창을 열 수 있지만 빠르게 스크롤하면 ListView
이 강제로 닫을 수 있습니다.
이 SSCCE
내 노트북에 효과를 유발하지만, 더 강력한 컴퓨터에 스크롤 동안 그것을 할 만 할 수있다 (혹은 대리인은 더 복잡해야 할 수도 있습니다) : 는import QtQuick 2.3
import QtQuick.Window 2.0
Window {
width: 300
height: 200
Component.onCompleted: {
win.createObject(null);
}
Component {
id: win
Window {
width: 600
height: 400
visible: true
ListView {
id: view
anchors.fill: parent
model: 100
boundsBehavior: Flickable.StopAtBounds
clip: true
delegate: Rectangle {
width: view.width
height: 24
property int debugLevel: index % 3
property int timestamp: index * 1000
property int message: index
color: "darkgray"
Row {
anchors.fill: parent
Repeater {
id: delegateRepeater
property list<QtObject> roleModel: [
QtObject {
property string label: timestamp
property int itemWidth: 100
},
QtObject {
property string label: debugLevel
property int itemWidth: 100
},
QtObject {
property string label: message
property int itemWidth: view.width - 100 - 100
}
]
model: roleModel
Item {
width: itemWidth
anchors {
top: parent.top
bottom: parent.bottom
}
Text {
anchors {
fill: parent
leftMargin: 4
}
verticalAlignment: Text.AlignVCenter
text: label
elide: Text.ElideRight
}
Rectangle {
anchors {
top: parent.top
bottom: parent.bottom
right: parent.right
}
width: 1
visible: index != (delegateRepeater.count - 1)
color: "white";
}
}
}
}
}
}
}
}
}
이되지 않습니다 을 제거하는 코드의 특정 부분 인 것 같습니다.의 대리자를 사용하면 하위 창이 닫힐 확률이 줄어 듭니다.
디버깅 태그를 추가했습니다. 가장 큰 문제는이 효과가 인데 디버그 결과가이 아니기 때문입니다. 서브 윈도우의 파괴 처리기 (Component.onDestruction
)에 중단 점을 추가하면 model: roleModel
문을 가리키는 단일 스택 항목이 있지만 - Repeater
전체를 제거하고 복사하여 붙여 넣은 것과 동일한 결과로 스택 항목을 뺀 결과가됩니다.
이 순수한 QML 예제에서 더 많은 정보를 얻는 방법을 아는 사람이라면 감사하게 생각합니다.
'win.createObject (null);은 부모가없는 윈도우를 생성하므로 리소스 해제가 트리거 될 때 QML 엔진이이 윈도우를 삭제/닫습니다. 'Window {id : root; Component.onCompleted : {win.createObject (루트); } /*...*/}'. – mcchu
@mcchu 생성 된 창의 수명은 이제 부모의 수명에 달려 있기 때문에 이는 솔루션이 아닙니다. 이는 기본적으로 응용 프로그램 동작을 변경합니다. – cmannett85