QML和c++的集成
QML and C++ intergration
这是我在这个论坛上的第一个帖子,因为我是一个Java人,所以我刚开始开发bb10和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);
}
现在,当从这个第二个屏幕,我试图打开第三页,它将不工作,请看到代码,告诉我他们做错了什么
您已经使用导航窗格,那么打开任何其他页面都没有问题。请看下面的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")
}
}
相关文章:
- 将公共但非静态的成员函数与ALGLIB集成
- 将IBM Rhapsody模型集成到VS 2019中
- 从R调用C++函数并对其进行集成时出错
- 如何集成 HID USB 控制器?
- 在VS2019项目中集成ImageMagick:x64-windows-static library
- 将Qt集成到现有的VS项目中以取代WinAPI
- 将 Crashpad 与 Windows Qt 应用程序集成
- Python3.6 模板中的 CGAL C++ 集成错误
- 基本 Cuda C++项目集成问题
- 如何使用CMake将QtMultimedia组件集成到项目中?
- 在 Mac OS 中将 QT 与 CMAKE 集成
- 使用 GSL 库制作样条曲线并使用它们进行集成
- 在集成终端上运行vscode lldb调试器时,如何获取程序的输出?
- 将Emscripten集成到Clion中
- VIsual Studio:避免控制台弹出,而是将其集成到IDE中
- 如何在electrolon项目中集成qt原生窗口
- 与 boost odeint 集成期间的析构函数调用
- C++uWebSockets将事件循环集成到一个线程中
- C++ 项目在 Jenkins 中的持续集成
- 将 ROOT 与 CMake 集成