How to get the base name from full file path
Unsolved
General and Desktop
-
I am using below code
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
QDir::currentPath(),
tr("txt (*.txt)"));it gives full path like C:\test\1.txt
I need to get only 1.txt how can I get it?
Thanks
-
-
const QFileInfo info(fileName); const QString file(info.fileName());
-
to add a 3rd way.
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath(), tr("txt (*.txt)")); fileName = QString(fileName.splitRef("/").last());