没有这样的信号bb :: cascades :: QmlListView :: triggered(QVariantList indexPath)

时间:2013-01-22 01:18:38

标签: qt qml signals-slots blackberry-10

我正在尝试在我的.qml文件中捕获ListView的信号,所以我正在做:

ListView *userList = root->findChild<ListView*>("userList");
Q_ASSERT(userList);

它获取列表,以及我尝试的时间:

Q_ASSERT(connect(userList, SIGNAL(triggered(QVariantList indexPath)), this, SLOT(onUserListTriggered(QVariantList indexPath))));

我收到此错误:

Object::connect: No such signal bb::cascades::QmlListView::triggered(QVariantList indexPath)
Object::connect:  (sender name:   'userList')
ASSERT: "connect(userList, SIGNAL(triggered(QVariantList indexPath)), this, SLOT(onUserListTriggered(QVariantList indexPath)))"

没有意义。 documentation of ListView告诉类发出此信号,我可以在标题listview.h中看到它

Q_SIGNALS:
/*!
        * @brief Emitted when a list item is triggered by the user.
        *
        * Typically, this signal is emitted when an item is tapped by the user 
        * with the intention to execute some action associated with it. 
        * This signal is, for example, not emitted when items are tapped 
        * during multiple selection, where the intention is to select the 
        * tapped item and not trigger an action associated with it.
        *
        * @param indexPath Index path to the triggered item.
        */
        void triggered(QVariantList indexPath);

2 个答案:

答案 0 :(得分:2)

将信号连接到插槽时仅指定参数的数据类型。将connect call语句替换为下面提到的语句。

bool ok = connect(userList, SIGNAL(triggered(QVariantList)), 
  this, SLOT(onUserListTriggered(QVariantList)));
// Q_ASSERT the bool so that the connect will be included in Release code
Q_ASSERT(ok);

答案 1 :(得分:0)

我还发现有必要放置完整的命名空间。这不是您的示例所必需的,但例如我必须这样做:

if (!connect(root, SIGNAL(popTransitionEnded(bb::cascades::Page*)), this,
    SLOT(navPagePopped(bb::cascades::Page*)))) {
    qDebug() << "UNABLE to connect popTransitionEnded to navPagePopped";
}

我猜测Qt框架在创建信号表时会使用参数的完整命名空间。