class uWidget : public QWidget
{
public:
uWidget()
{
QCompleter * completer = new QCompleter(this);
QFileSystemModel * model = new QFileSystemModel(completer);
model->setFilter(QDir::Dirs | QDir::Drives | QDir::AllDirs);// | QDir::NoDotAndDotDot);
model->setRootPath(tr("D:"));
completer->setModel(model);
QHBoxLayout* layout = new QHBoxLayout(this);
QPushButton* button = new QPushButton("Click");
QLineEdit* edit = new QLineEdit();
layout->addWidget(button);
layout->addWidget(edit);
edit->setCompleter(completer);
}
};