In my app I have a custom item derived from QObject. In specified moment I need to access its parent. But since this item is not QQuickItem descendant there is no parentItem()
here.
QML:
Item {
id: root
MyItem {
id: myitem
}
}
C++
class MyItem : public QObject {
public:
explicit MyItem(QObject *parent = 0) {
// parent is always NULL here
}
}
So my question - how can I access parent of non-visual QML item in C++?
QObject
has theparent()
method. – Dmitry Sokolov