2013-06-18 32 views
-1

这是我在这个论坛上的第一篇文章,刚刚开始BB 10开发,还有C++,因为我是Java Person。我有在QML和一些问题的C++一体化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); 
} 

现在,当从第二个屏幕,我尝试打开锡尔d页面根本无法正常工作,请查看代码并告诉我他们做错了什么

+1

如果你的问题是关于QML集成,你应该表现出你的QML代码。顺便说一句,我建议与qDebug()<<“你的日志”登录; – Benoit

回答

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" 
        } 
       ] 
      } 
     } 
    } 

} 

DetailsPage.qml

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

}