ok so when I select items in my tree and execute selectedItems() it just works as intended using this function:
void Getmyfiltr::on_pushButton_clicked(){
QList <QTreeWidgetItem *> selection;
selection << ui.treeWidget->selectedItems();
for(int i=0;i<selection.size();i++){
qDebug() << selection.at(i)->text(0);
}
qDebug() << selection.size();
}
but when I use my lineEdit to filter the content using that on_lineEdit_textChanged( const QString &) function and then hit the pushButton it just crashes the application with a segfault.
void Getmyfiltr::on_lineEdit_textChanged( const QString & filtr)
{
//QAbstractItemModel *sourceModel;
//TreeSortFilter is a subclass of QSortFilterProxyModel to search through children
TreeSortFilter *proxyModel = new TreeSortFilter(this);
proxyModel->setSourceModel(sourceModel);
ui.treeWidget->QTreeView::setModel(proxyModel);
QRegExp rx(filtr, Qt::CaseInsensitive);
proxyModel->setFilterRegExp(rx);
ui.treeWidget->QTreeView::setModel(proxyModel);
}
using qDebug() I can see that it's crashing on "selection.at(i)->text(0)". Also what I noticed is that when I check qDebug() << selection.size() before filtering it does indicate the normal number of selected items but after I use the filter, it only counts the parents of each children selected. so if I select 10 children from 3 differents parents selection.size() will only return 3.
Any idea what's wrong?
thanx in advance
Pat
Bookmarks