qobject_cast<QFileSystemModel*> (sourceModel ())->fileinfo(source_parent);
(qobject_cast<QFileSystemModel*> (sourceModel ()))->fileinfo(source_parent);
QFileSystemModel * fileSystemModel = qobject_cast<QFileSystemModel*> (sourceModel());if (fileSystemModel) { const QFileInfo & info = fileSystemModel->fileinfo(source_parent); qDebug() << info.absolutePath();}
QFileSystemModel *t=qobject_cast<QFileSystemModel*> (sourceModel()); QString str=t->fileInfo(source_parent).absoluteFilePath();
QMessageBox msg; msg.setText(str); msg.exec
QFileSystemModel *t=qobject_cast<QFileSystemModel*> (sourceModel()); QString str=t->fileInfo(source_parent).absoluteFilePath(); QFileSystemModel *fileSystemModel = qobject_cast<QFileSystemModel*> (sourceModel()); if (fileSystemModel) { const QFileInfo & info=fileSystemModel->fileInfo(source_parent); QString str= info.absoluteFilePath(); QMessageBox msg; msg.setText(str); msg.exec(); return true; }
... if (fileSystemModel) { const QFileInfo & info=fileSystemModel->fileInfo(source_parent); ...
C++ (Qt)bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex & source_parent) const [virtual protected]
if ((str=="/" && source_row==32) || (str=="/" && source_row==42){ return true;}else{ return false;}
bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const{ QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent); QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent); QModelIndex index2 = sourceModel()->index(sourceRow, 2, sourceParent); return (sourceModel()->data(index0).toString().contains(filterRegExp()) || sourceModel()->data(index1).toString().contains(filterRegExp())) && dateInRange(sourceModel()->data(index2).toDate());}
bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow,const QModelIndex &sourceParent){ QMessageBox msg; QModelIndex resource=sourceModel()->index(source_row,0,source_parent); // проходимся по всем строкам и суем их в Modelindex QFileSystemModel *fileSystemModel = qobject_cast<QFileSystemModel*> (sourceModel()); if (fileSystemModel) { const QFileInfo & info2=fileSystemModel->fileInfo(resource); QString str=info2.absoluteFilePath(); //берем абсолютный путь reosurce if (str.contains("/root")) // если путь содержит папку { return sourceModel()->data(resource).toString().contains("/root"); //как в примере } else { return false; } }}