导航窗格从C++;BB10 我现在只在C++中创建我的应用程序,我创建导航窗格并添加容器,我需要的视图。它工作正常,但我想捕获一个单击的按钮,使NavigationPane弹出当前页面,并推送一个不同的(运行时生成的)页面
这是如何实现的,我试着处理信号,但我想我不知道它是如何工作的信号和QT_插槽,在NavigationPane的情况下,它没有QT_插槽那样的方法导航窗格从C++;BB10 我现在只在C++中创建我的应用程序,我创建导航窗格并添加容器,我需要的视图。它工作正常,但我想捕获一个单击的按钮,使NavigationPane弹出当前页面,并推送一个不同的(运行时生成的)页面,c++,blackberry-10,C++,Blackberry 10,这是如何实现的,我试着处理信号,但我想我不知道它是如何工作的信号和QT_插槽,在NavigationPane的情况下,它没有QT_插槽那样的方法 任何建议都将不胜感激。您首先需要将按钮的点击信号连接到导航窗格的pop()插槽。应该是这样的: // Connect the button's clicked() signal to the navigation pane's // pop() slot. bool connectResult = QObject::connect(myButton
任何建议都将不胜感激。您首先需要将
按钮的点击信号连接到导航窗格的pop()
插槽。应该是这样的:
// Connect the button's clicked() signal to the navigation pane's
// pop() slot.
bool connectResult = QObject::connect(myButton,
SIGNAL(clicked()),
myPane,
SLOT(pop()));
// Use the Q_ASSERT() function to test the return value and
// generate a warning message if the signal slot connection
// wasn’t successful.
Q_ASSERT(connectResult);
// Indicate that the variable connectResult isn't used in the
// rest of the app to prevent a compiler warning.
Q_UNUSED(connectResult);
有关的此页面可能会帮助您了解如何处理此问题。为了更好地理解如何将对象连接在一起,您可能还想看看signals和slots文档
然后,您必须在弹出后创建并推送新页面。要做到这一点,只需将NavigationPane
的popTransitionEnded(bb::cascades::Page*页)
插槽连接到将执行此任务的自定义函数
bool connectResult = QObject::connect(myPane,
SIGNAL(popTransitionEnded(bb::cascades::Page*)),
this,
SLOT(createNewPageAndPushIt(bb::cascades::Page*)));
Q_ASSERT(connectResult);
Q_UNUSED(connectResult);
有关使用NavigationPane堆叠页面的更多详细信息,请参阅。您首先需要将按钮的单击()
信号连接到NavigationPane
的pop()
插槽。应该是这样的:
// Connect the button's clicked() signal to the navigation pane's
// pop() slot.
bool connectResult = QObject::connect(myButton,
SIGNAL(clicked()),
myPane,
SLOT(pop()));
// Use the Q_ASSERT() function to test the return value and
// generate a warning message if the signal slot connection
// wasn’t successful.
Q_ASSERT(connectResult);
// Indicate that the variable connectResult isn't used in the
// rest of the app to prevent a compiler warning.
Q_UNUSED(connectResult);
有关的此页面可能会帮助您了解如何处理此问题。为了更好地理解如何将对象连接在一起,您可能还想看看signals和slots文档
然后,您必须在弹出后创建并推送新页面。要做到这一点,只需将NavigationPane
的popTransitionEnded(bb::cascades::Page*页)
插槽连接到将执行此任务的自定义函数
bool connectResult = QObject::connect(myPane,
SIGNAL(popTransitionEnded(bb::cascades::Page*)),
this,
SLOT(createNewPageAndPushIt(bb::cascades::Page*)));
Q_ASSERT(connectResult);
Q_UNUSED(connectResult);
有关使用NavigationPane堆叠页面的更多详细信息,请参阅。--------------尝试此操作-------------
从my github示例中获取示例应用程序以用于您的查询
main.qml:(第一页)
2.第二页
import bb.cascades 1.0
Page {
id: pageTwo
Container {
background: Color.Gray
layout: DockLayout {
}
Label {
text: "Second page"
horizontalAlignment: HorizontalAlignment.Center
}
Container {
layout: StackLayout {
}
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
Button {
text: qsTr("Next Page")
imageSource: "asset:///images/picture1thumb.png"
onClicked: {
// show detail page when the button is clicked
var page = getSecondPage();
console.debug("pushing detail " + page)
navigationPane.push(page);
}
property Page secondPage
function getSecondPage() {
if (! secondPage) {
secondPage = secondPageDefinition.createObject();
}
return secondPage;
}
attachedObjects: [
ComponentDefinition {
id: secondPageDefinition
source: "PageTwoOne.qml"
}
]
}
Button {
text: "Previous Page"
onClicked: {
navigationPane.pop();
}
}
}
}
/*------如果后退按钮可见性为“True”,则使用此代码-----------------
3.最后一页
import bb.cascades 1.0
Page {
id: pageTwoone
Container {
background: Color.DarkGray
layout: DockLayout {}
Label {
horizontalAlignment: HorizontalAlignment.Center
text: "Last Page"
}
Container {
layout: StackLayout {}
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
Button {
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
text: qsTr("Goto Home Page")
onClicked: {
// show detail page when the button is clicked
navigationPane.navigateTo(rootPage);
}
}
Button {
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
text: qsTr("Goto Back")
onClicked: {
// show detail page when the button is clicked
navigationPane.pop();
}
}
}
}
}
------------使用此代码添加更多要导航的页面----------------------------
-------------复制此代码并运行。。如果需要,请从上面的链接获取示例应用程序--------------------------尝试此操作-------------
从my github示例中获取示例应用程序以用于您的查询
main.qml:(第一页)
2.第二页
import bb.cascades 1.0
Page {
id: pageTwo
Container {
background: Color.Gray
layout: DockLayout {
}
Label {
text: "Second page"
horizontalAlignment: HorizontalAlignment.Center
}
Container {
layout: StackLayout {
}
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
Button {
text: qsTr("Next Page")
imageSource: "asset:///images/picture1thumb.png"
onClicked: {
// show detail page when the button is clicked
var page = getSecondPage();
console.debug("pushing detail " + page)
navigationPane.push(page);
}
property Page secondPage
function getSecondPage() {
if (! secondPage) {
secondPage = secondPageDefinition.createObject();
}
return secondPage;
}
attachedObjects: [
ComponentDefinition {
id: secondPageDefinition
source: "PageTwoOne.qml"
}
]
}
Button {
text: "Previous Page"
onClicked: {
navigationPane.pop();
}
}
}
}
/*------如果后退按钮可见性为“True”,则使用此代码-----------------
3.最后一页
import bb.cascades 1.0
Page {
id: pageTwoone
Container {
background: Color.DarkGray
layout: DockLayout {}
Label {
horizontalAlignment: HorizontalAlignment.Center
text: "Last Page"
}
Container {
layout: StackLayout {}
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
Button {
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
text: qsTr("Goto Home Page")
onClicked: {
// show detail page when the button is clicked
navigationPane.navigateTo(rootPage);
}
}
Button {
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
text: qsTr("Goto Back")
onClicked: {
// show detail page when the button is clicked
navigationPane.pop();
}
}
}
}
}
------------使用此代码添加更多要导航的页面----------------------------
-------------复制此代码并运行。。如果需要,从上面的链接获取示例应用程序------您检查过这个吗?
解释:
ObjectNavigationPane的一个实例允许使用push/pop效果将当前页面更改为其他页面(见图):
developer.blackberry.com/native/files/reference/cascades/images/navigation\u pane\u push\u pop.png
你必须特别注意:
navigationPane=navigationPane::create()代码>
并告诉应用程序您将使用此实例更改页面:
Application::instance()->setScene(导航窗格)代码>
现在你的应用程序有了导航窗格,但里面什么都没有,如果你运行它,你会看到一个黑屏,要添加一个页面(主页-page0),请使用push:
navigationPane->push(页面::创建()
.内容(标签::创建(“第一页”))代码>
要添加一个可以返回页面的新页面0,我们只需再次按下use push,请记住包括返回按钮以返回:
navigationPane->push(页面::创建()
.内容(标签::创建(“第二页”))
.paneProperties(导航paneProperties::create()
.backButton(ActionItem::create()
.标题(“上一页”)
.imageSource(QUrl)(“asset:///back.png“”)//您应该手动添加此图像。
.OnTiggered(导航窗格,插槽(pop()));
Q_可调用的void insert(intindex,bb::cascades::Page*Page)
在NavigationPane中的指定索引处插入页面
传递的页面不能为0,否则将被忽略。如果
页面已存在于导航堆栈中,操作将
失败。此操作不会触发转换效果,即使
页面被添加到堆栈的顶部
如果需要,请改用push()。将发出topChanged()信号
如果操作影响顶部节点
参数
1-索引
将放置页面的索引。如果索引<0,则将页面插入底部。如果索引>导航堆栈中的页数,则将其添加到堆栈顶部。
第2页
要插入的页面不能为0
自:黑莓10.0.0
一个想法是
您可以使用:
navigationPane.count()
获取nagationPane堆栈中的当前页面,并使用:
navigationPane.insert(navigationPane.count()-1,MyPageToBack);
在当前页面和当前页面之间推送页面
前一个
你检查过这个了吗?
解释:
ObjectNavigationPane的一个实例允许使用push/pop效果将当前页面更改为其他页面(见图):
developer.blackberry.com/native/files/reference/cascades/images/navigation\u pane\u push\u pop.png
你必须特别注意:
navigationPane=navigationPane::create();
告诉