首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无此信号bb::cascades::QmlListView::triggered(QVariantList indexPath)

无此信号bb::cascades::QmlListView::triggered(QVariantList indexPath)
EN

Stack Overflow用户
提问于 2013-01-22 09:18:38
回答 2查看 646关注 0票数 0

我试图在我的.qml文件中捕获ListView信号,所以我这样做:

代码语言:javascript
复制
ListView *userList = root->findChild<ListView*>("userList");
Q_ASSERT(userList);

它得到列表,当我尝试的时候:

代码语言:javascript
复制
Q_ASSERT(connect(userList, SIGNAL(triggered(QVariantList indexPath)), this, SLOT(onUserListTriggered(QVariantList indexPath))));

我得到了这个错误:

代码语言:javascript
复制
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中看到它

代码语言:javascript
复制
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);
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-01-22 12:45:52

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

代码语言:javascript
复制
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);
票数 2
EN

Stack Overflow用户

发布于 2013-01-22 16:06:23

我还发现有必要将完整的名称空间。对于您的示例,这不是必需的,但例如,我必须这样做:

代码语言:javascript
复制
if (!connect(root, SIGNAL(popTransitionEnded(bb::cascades::Page*)), this,
    SLOT(navPagePopped(bb::cascades::Page*)))) {
    qDebug() << "UNABLE to connect popTransitionEnded to navPagePopped";
}

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14450058

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档