QModelIndex VirtualSystemModel::parent(const QModelIndex &idx) const { if (!idx.isValid()) return QModelIndex(); ModelItem *childItem = static_cast<ModelItem*>(idx.internalPointer()); ModelItem *parentItem = childItem->parent(); if (parentItem == m_pRootItem) return QModelIndex(); return createIndex(parentItem->row(), 0, parentItem); }