我试图在我的.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);发布于 2013-01-22 12:45:52
在将信号连接到插槽时仅指定参数的数据类型。用下面提到的语句替换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);发布于 2013-01-22 16:06:23
我还发现有必要将完整的名称空间。对于您的示例,这不是必需的,但例如,我必须这样做:
if (!connect(root, SIGNAL(popTransitionEnded(bb::cascades::Page*)), this,
SLOT(navPagePopped(bb::cascades::Page*)))) {
qDebug() << "UNABLE to connect popTransitionEnded to navPagePopped";
}我猜测Qt框架在创建信号表时使用了完整的参数命名空间。
https://stackoverflow.com/questions/14450058
复制相似问题