- 在我的应用程序中,我正在使用导航窗格。我想为每个 QML 制作单独的文件假设这是我的文件
应用程序ui.cpp
// initial load
// Create scene document from main.qml asset, the parent is set
// to ensure the document gets destroyed properly at shut down.
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
// Create root object for the UI
AbstractPane *root = qml->createRootObject<AbstractPane>();
// Set created root object as the application scene
app->setScene(root);
2.这里我正在加载main.qml是这样的
import bb.cascades 1.0
NavigationPane {
id: navigationPane
Page {
titleBar: TitleBar {
// Localized text with the dynamic translation and locale updates support
title: qsTr("Page 1") + Retranslate.onLocaleOrLanguageChanged
}
Container {
}
actions: ActionItem {
title: qsTr("Second page") + Retranslate.onLocaleOrLanguageChanged
ActionBar.placement: ActionBarPlacement.OnBar
onTriggered: {
// A second Page is created and pushed when this action is triggered.
navigationPane.push(secondPageDefinition.createObject());
}
}
}
attachedObjects: [
// Definition of the second Page, used to dynamically create the Page above.
ComponentDefinition {
id: secondPageDefinition
source: "DetailsPage.qml"
}
]
onPopTransitionEnded: {
// Destroy the popped Page once the back transition has ended.
page.destroy();
}
}
3.在这个文件中,我调用“DetailsPage.qml”文件,看起来像这样
import bb.cascades 1.0
Page {
titleBar: TitleBar {
// Localized text with the dynamic translation and locale updates support
title: qsTr("Second Page") + Retranslate.onLocaleOrLanguageChanged
}
Container {
Label {
id: msgLabel
objectName: "msgLabel"
}
}
}
第 1 步:如何为 DetailsPage.qml 创建单独的 .cpp 和 .hh 文件
第 2 步:我想要这个,因为我在 .cpp 和 .hh 中进行网络操作并在 QML 中进行设计。
第 3 步:我在这里感到困惑的主要原因是,如果我从 QML 导航,那么完全控制权在 QML,反之亦然。在堆栈上,qml 首先可以识别它的 c++ 文件,但如果堆栈增加,那么我们应该如何做到这一点。
--------如果你不明白我的问题,请告诉我----