ListViewコンポーネントを使用していますが、currentIndex
プロパティで問題があります。私はQml listViewミラーリングレイアウトの現在のインデックス
onCurrentIndexChanged:
に何らかのアクションをしたいしかし、私が使用している場合
LayoutMirroring.enabled: true
currentIndex
onCurrentIndexChanged
にはアクションはありません。また、currentIndexは常に0になります。 私も使用しようとしました
layoutDirection: Qt.RightToLeft
しかし、問題は同じです(リストビューを移動したときには
currentIndex
の更新はありません)。
あなたは
snapMode: ListView.SnapToItem
を使用する場合にもcurrentIndexするために
highlightRangeMode: ListView.StrictlyEnforceRange
を追加する必要があることを、私はリストビューのドキュメントを読んで、情報がありましたが、正しくアップデートです。たぶん、ミラーレイアウトに似たものがありますか?
ここが全体のコードです:
ListView
{
id: id_couplingControlView
model: id_multiCouplingMeasurePopup.p_iCouplingsCount
orientation: ListView.Horizontal
snapMode: ListView.SnapToItem
highlightRangeMode: ListView.StrictlyEnforceRange //To update the currentIndex as the list is moved
preferredHighlightBegin: id_multiCouplingMeasurePopup.p_bViewRotated ? id_couplingControlView.width : id_couplingControlView.leftMargin
LayoutMirroring.enabled: id_multiCouplingMeasurePopup.p_bViewRotated
//layoutDirection: id_multiCouplingMeasurePopup.p_bViewRotated ? Qt.RightToLeft : Qt.LeftToRight
delegate: QmlSHMultiCouplingMeasureControl
{
id: id_CouplingMeasureControl
p_iIndex: index
Component.onCompleted:
{
InitializeCouplingControl (id_CouplingMeasureControl)
}
}
//Need to to something here
onCurrentIndexChanged:
{
console.log ("onCurrentIndexChanged:: " + id_couplingControlView.currentIndex)
id_multiCouplingMeasurePopup.UpdateMiniTrainCouplingList(id_couplingControlView.currentIndex);
}
}
だから私の質問はです:私はLayoutMirroring.enabled: true
またはlayoutDirection: Qt.RightToLeft
を使用している場合、リストビューをスクロールしながらcurrentIndex
が更新持って何をする必要がありますか。
-1:**質問が欠落しています** *何が起こっている、あなたがしたくありません* - ? *私はあなたのコードを実行することができません問題を参照してください。*ミラーリングされた 'ListView'を試したとき、すべてが期待どおりに動作します。指定してください。 – derM
投稿の最後に質問を更新しました。 – Kostek