我想趕上我.qml文件一個ListView的信號,所以我做:沒有這樣的信號BB ::級聯:: QmlListView ::觸發(QVariantList indexPath)
它得到的名單,而當我嘗試:
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);
沒錯,謝謝! –
這是_VERY WRONG_。 'connect'代碼很好,但是將其封裝在'Q_ASSERT'中意味着它將在Release版本中被排除。換句話說,它可以在你的調試版本中正常工作,只要你釋放你的代碼,'connect'永遠不會被調用。有關詳細信息,請參閱http://stackoverflow.com/questions/12573230/q-assert-release-build-semantics。我已經在上面編輯過來糾 – craigmj
恩,謝謝你的糾正。 –