アプリのメインメソッドにコンテキストオブジェクトを設定しました。
// Load the UI description from main.qml
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(&app);
// Make the Corporate object available to the UI as context property
qml->setContextProperty("_corporate", new Corporate(&app));
しかし、onTouch
メソッド内から_corporateオブジェクトにアクセスすることはできませんが、同時に_corporateオブジェクトはonTriggeredメソッドで適切にアクセスされます。コードは次のとおりです。
ListView {
dataModel: _corporate.model
id: myListView
listItemComponents: [
ListItemComponent {
id: groupItemComponent
type: "groupItem"
StandardListItem {
id: groupListItem
title: qsTr ("%1").arg(ListItemData.firstRow)
description: ListItemData.secondRow
onTouch: {
_corporate.currentView = 3
}
}
}
]
onTriggered: {
_corporate.currentView = 3
}
}
私は何が間違っているのですか?