2013-06-18 35 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") 
} 

}