-1

这是我在这个论坛上的第一篇文章,刚刚开始 BB 10 开发和 C++,因为我是 Java Person。我在 QML 和 C++ 集成中遇到了一些问题

这是我想要做的:

我有登录页面,在登录按钮上单击我的新页面(这是一个导航窗格)打开没有任何问题这是我使用的方法

void Integration:penNextPage() {
    printLog("-- open second page (a navigation pane ");
    new SecondPageHndlr (appRefrence);
}

这是我在 SecondPageHndlr 类中所做的:

SecondPageHndlr.cpp
#include "SecondPageHndlr.hpp"
#include "ThirdPageHndlr.hpp"
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <bb/cascades/NavigationPane>
#include <bb/cascades/Page>
#include <bb/cascades/Sheet>
#include <QObject>
#include <QIODevice>
#include <iostream.h>
#include <string.h>
#include <stdio.h>
using namespace bb::cascades;
SecondPageHndlr::SecondPageHndlr(bb::cascades::Application *app)
: QObject(app){
    try{
            QmlDocument *secondQml = QmlDocument::create("asset:///SecondPage.qml");
            if (!secondQml->hasErrors()) {
                NavigationPane* page = secondQml->createRootObject<NavigationPane>();
                if (page)
                {
                    printLog("second page view . page is not  null ");
                    //make this c++ file accessable from the dashboardviewn.qml
                    pane = page;
                    secondQml->setContextProperty("second", this );
                    app->setScene(page);
                }
                else
                    printLog("page is null ");
            }
            else
                printLog("Error in second page view QML");
        }
        catch (std::exception& e)
        {
            printLog("-------- Exception");
            std::cout << "Exception: " << e.what();
        }
}
void SecondPageHndlr::showThirdScreen(){
    printLog("-- open Third page (a navigation pane pushes a new page");
    new ThirdPageHndlr (pane);
}
void SecondPageHndlr::printLog(const char *str){
    cout <<"\n" << str ;
    printf("" ,1);
    fflush(stdout);
}

现在,当我从第二个屏幕尝试打开第三页时,它根本不起作用,请查看代码并告诉我他们做错了什么

4

1 回答 1

0

您已经在使用导航窗格,那么打开任何其他页面都没有问题。看下面的qml代码

import bb.cascades 1.0

NavigationPane {
    id: navigationPane
    Page {
        // page with a picture thumbnail
        Container {
            background: Color.Gray
            layout: DockLayout {
            }
            Button {
                horizontalAlignment: HorizontalAlignment.Center
                verticalAlignment: VerticalAlignment.Center
                text: qsTr("Show detail")
                onClicked: {
                    // show detail page when the button is clicked
                    var page = secondPageDefinition.createObject();
                    console.debug("pushing detail " + page)
                    navigationPane.push(page);
                }
                  attachedObjects: [
                    ComponentDefinition {
                        id: secondPageDefinition
                        source: "DetailsPage.qml"
                    }
                ]
            }
        }
    }

}

详细信息页面.qml

Page{
  Label{
text: qsTr("Second Page")
}

}

于 2013-07-09T04:57:39.640 回答