#include#include QString filePath = "/Users/username/Documents/sample.txt"; QFileInfo fileInfo(filePath); qDebug() << fileInfo.completeBaseName(); // Output: sample
#includeIn this example, the complete base name of the file path "~/Pictures/cat.jpg" is "cat". Package library: Qt#include QString filePath = "~/Pictures/cat.jpg"; QFileInfo fileInfo(filePath); qDebug() << fileInfo.completeBaseName(); // Output: cat