我试图在我的 .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)))"
这没有道理。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);