Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

QTreeWidgetItem * QTreeWidget::takeTopLevelItem ( int  index  ) 

Removes the top-level item at the given index in the tree and returns it, otherwise returns 0;

Definition at line 1914 of file qtreewidget.cpp.

References QList< T >::at(), QTreeWidgetItem::children, QList< T >::count(), QVector< T >::isEmpty(), QAbstractItemView::model(), QTreeWidgetItem::model, QStack< T >::pop(), QStack< T >::push(), and QTreeWidgetItem::view.

{
    Q_D(QTreeWidget);
    if (index >= 0 && index < d->model()->tree.count()) {
        d->model()->beginRemoveRows(QModelIndex(), index, index);
        QTreeWidgetItem *item = d->model()->tree.takeAt(index);
        QStack<QTreeWidgetItem*> stack;
        stack.push(item);
        while (!stack.isEmpty()) {
            QTreeWidgetItem *i = stack.pop();
            i->view = 0;
            i->model = 0;
            for (int c = 0; c < i->children.count(); ++c)
                stack.push(i->children.at(c));
        }
        d->model()->endRemoveRows();
        return item;
    }
    return 0;
}


Generated by  Doxygen 1.6.0   Back to index