我现在仅使用 C++ 创建我的应用程序,我创建了 NavigationPane 并添加了包含我需要的 View 的容器。它工作正常,但我想捕获一个单击的按钮,以使导航 Pane 弹出当前页面并推送不同的(在运行时创建的)页面。
如何实现它,我尝试使用信号,但我认为我不明白信号和 QT_SLOTS 是如何工作的,在 NavigationPane 的情况下,它没有 QT_SLOT 那样的方法。如有任何建议,我们将不胜感激。
最佳答案
您首先需要将 Button
的 clicked()
信号连接到 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);
此页面关于 buttons可能会帮助您了解如何处理这个问题。为了更好地理解如何将对象连接在一起,您可能还需要查看信号和槽文档。
然后,您必须在弹出后创建并推送新页面。为此,您只需将 NavigationPane
的 popTransitionEnded (bb::cascades::Page *page)
插槽连接到将完成这项工作的自定义函数。
bool connectResult = QObject::connect(myPane,
SIGNAL(popTransitionEnded(bb::cascades::Page*)),
this,
SLOT(createNewPageAndPushIt(bb::cascades::Page*)));
Q_ASSERT(connectResult);
Q_UNUSED(connectResult);
参见this page有关使用 NavigationPane 堆叠页面的更多详细信息。
关于c++ - 来自 C++ BB10 的导航 Pane 弹出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18496569/