Getting only the folder path to a line edit without selecting any file
Solved
General and Desktop
-
In my Qt c++ application I want to get a folder path into a line edit without selecting anyfile!
void MainWindow::on_button_clicked()
{filePath=QFileDialog::getOpenFileName(this, "Get Any File"); QDir d = QFileInfo(filePath).absoluteDir(); QString absolute=d.absolutePath(); ui->lineEdit->setText(absolute);
}
currently I use the above code to achieve it! Though the folder path only appears(without the file name) in the line edit a file in the relevant folder should be selected for it! I want to get folder path without selecting any file. (folder path should appear by opening the folder only)how can I get this done?
-
try
filePath=QFileDialog::getExistingDirectory(this, "Get Any File"); -
just use the filePath without further modification, its already the complete path.
This codeQDir d = QFileInfo(filePath).absoluteDir(); QString absolute=d.absolutePath();
will lead you to the dir above the selected path...
3/4