0

我有一个导航窗格,我禁用了 main.qml 中的后退按钮,但是我想再次在应用程序的某些部分显示后退按钮。我该如何实施?这是我的cpp

pane = qml->createRootObject<NavigationPane>();

    // Set created root object as the application scene
    app->setScene(pane);

    qml->setContextProperty("cppObj", this);

}

void ApplicationUI::onLoginClicked() {
    // create scene document from buttonclicked.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///projects.qml").parent(this);
    qml->setContextProperty("cppObj", this);
    Page* root = qml->createRootObject<Page>();
    pane->push(root);
}

void ApplicationUI::onAddClicked() {
    // create scene document from buttonclicked.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///addprojects.qml").parent(this);
    Page* root = qml->createRootObject<Page>();
    pane->push(root);
}

这是我禁用后退按钮的主要内容

NavigationPane {
    backButtonsVisible: false }

如何使应用程序的某些部分的后退按钮处于活动状态?

4

1 回答 1

1

假设您有以下代码:

首页

import bb.cascades 1.0

NavigationPane {
    id: navPane

    Page {
        Container {
            horizontalAlignment: HorizontalAlignment.Fill
            verticalAlignment: VerticalAlignment.Fill
            layout: DockLayout {
            }
            Button {
                horizontalAlignment: HorizontalAlignment.Center
                verticalAlignment: VerticalAlignment.Center
                text: "Next Page"
                onClicked: {
                    var nextPage = page.createObject();
                    navPane.push(nextPage);
                }
            }
        }
    }

    attachedObjects: [
        ComponentDefinition {
            id: page
            source: "NextPage.qml"
        }
    ]
}

下一页:

import bb.cascades 1.0

Page {
    // disables backButton (not peeking)
    paneProperties: NavigationPaneProperties {
            backButton: ActionItem {
            enabled: false
        }
    }

    // [0]
    Container {
        horizontalAlignment: HorizontalAlignment.Fill
        verticalAlignment: VerticalAlignment.Fill
        layout: DockLayout {
        }
        Button {
            horizontalAlignment: HorizontalAlignment.Center
            verticalAlignment: VerticalAlignment.Center
            text: "Prev page"
            onClicked: {
                var page = navPane.pop();
                if (page)
                    page.destroy();
            }
        }
    } // [0]

    // hides navigation bar
    onCreationCompleted: {
        navPane.backButtonsVisible = false;
    }
}

backButton然后你可以用这个代码完全禁用NextPage.qml

onCreationCompleted: {
    navPane.backButtonsVisible = false;
}

或者,如果您希望导航窗格可见但仅禁用后退按钮,请在同一NextPage.qml文件中使用以下内容:

paneProperties: NavigationPaneProperties {
    backButton: ActionItem {
        enabled: false
    }
}

另外,不要忘记peekEnabled财产。使用 peek BB10 功能,用户可以使用滑动手指移动在同级页面之间移动,而无需触摸屏幕上的任何按钮。

可以用类似的方式完成:

onCreationCompleted: {
    navPane.peekEnabled = false;
}

希望能帮助到你。

于 2013-07-05T03:29:30.733 回答