I'm creating a text editor using QT Widgets, with tabs like VS Code, and when I open a file with QFileDialog
I want to rename the tab title to the name of the file just like normal text editor do, I've found the QFileDialog::getOpenFileName()
but that method returns the full path, and I want to return only the file name. Is it possible ?
Asked
Active
Viewed 741 times
1

Fady's Cube
- 158
- 1
- 7
-
1You can easily remove the path for display however you most likely need the path if you are going to open the file. – drescherjm Aug 19 '21 at 22:59
-
but the path format is different for each OS in Unix `/home/user/...` and in Windows `C:\Users\username\...` – Fady's Cube Aug 19 '21 at 23:01
-
1Qt has functions to do this for you. – drescherjm Aug 19 '21 at 23:01
-
Which function ? – Fady's Cube Aug 19 '21 at 23:02
-
4https://doc.qt.io/qt-5/qfileinfo.html#fileName – drescherjm Aug 19 '21 at 23:03
-
Thank you for your help ! – Fady's Cube Aug 19 '21 at 23:04
-
fileName method in the FileInfo interface – ΦXocę 웃 Пepeúpa ツ Aug 20 '21 at 06:20