QList
QMLからC++コードに整数を渡そうとしていますが、どういうわけか私のアプローチは機能していません。以下のアプローチでは、次のエラーが発生します。
left of '->setParentItem' must point to class/struct/union/generic type
type is 'int *'
問題をトラブルシューティングするための入力は大歓迎です
以下は私のコードスニペットです
ヘッダーファイル
Q_PROPERTY(QDeclarativeListProperty<int> enableKey READ enableKey)
QDeclarativeListProperty<int> enableKey(); //function declaration
QList<int> m_enableKeys;
cppファイル
QDeclarativeListProperty<int> KeyboardContainer::enableKey()
{
return QDeclarativeListProperty<int>(this, 0, &KeyboardContainer::append_list);
}
void KeyboardContainer::append_list(QDeclarativeListProperty<int> *list, int *key)
{
int *ptrKey = qobject_cast<int *>(list->object);
if (ptrKey) {
key->setParentItem(ptrKey);
ptrKey->m_enableKeys.append(key);
}
}