#include "myfileselect.h" #include #include MyFileSelect::MyFileSelect(QWidget* parent) : QFileDialog(parent) { this->setViewMode(QFileDialog::List); this->setFileMode(QFileDialog::ExistingFiles); this->setFilter(QDir::System | QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); QDialogButtonBox* button = this->findChild("buttonBox"); disconnect(button, SIGNAL(accepted()), this, SLOT(accept())); connect(button, SIGNAL(accepted()), this, SLOT(goAccept())); QLineEdit *fileNameEdit = this->findChild("fileNameEdit"); connect(this, &MyFileSelect::currentChanged, this, [=](const QString& path){ fileNameEdit->setText(path.section('/', -1)); }); } void MyFileSelect::goAccept() { QDialog::accept(); }