if (event->type() == QEvent::KeyPress) { //QDir dir; QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); QFileSystemModel *model = new QFileSystemModel; if (keyEvent->key()==Qt::Key_Return) { if(model->fileInfo(ui->left_pole->currentIndex()).isFile()) { return false; } else { left_pole_update(ui->left_pole->currentIndex()); } } }
ASSERT: "index.model() == q" in file dialogs\qfilesystemmodel.cpp, line 1270Invalid parameter passed to C runtime function.Invalid parameter passed to C runtime function.
bool MainWindow::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::KeyPress) { //QDir dir; QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); QFileSystemModel *model = new QFileSystemModel; if (keyEvent->key()==Qt::Key_Return) { if(model->fileInfo(ui->left_pole->currentIndex()).isFile()) { return false; } else { left_pole_update(ui->left_pole->currentIndex()); } } }return QMainWindow::eventFilter(obj, event); }
QItemSelectionModel *selectionModel = view->selectionModel(); QModelIndexList indexes = selectionModel->selectedIndexes(); // или selectedRows foreach(QModelIndex index, indexes) { qDebug() << model->filePath(index); // печатаем выделенные файлы } selectionModel->clear(); QModelIndex index = model->index("/"); // индекс корня в линупсе selectionModel->select(index); // выделен рут
model_l->mkdir(?,filename);