我从Qt GUI将一个文件列表收集到一个QStringList中.这些文件中的每一个都是一个.txt文件,其中包含相应的视频文件same_folder_as_txt/videos/.
有没有一种简单的方法可以将QString对象作为文件路径进行操作?例如,给定C:/some/path/foo.txt,我想要检索C:/some/path/videos/foo.avi
Pie*_* GM 10
鉴于你的道路 QString s
info = QFileInfo(s)
// Get the name of the file without the extension
base_name = info.baseName()
// Add a ".avi" extension
video_file = QStringList((base_name, "avi")).join(".")
// Get the directory
dir_name = info.path()
// Construct the path to the video file
video_path = QStringList((dir_name, QString("videos"), video_file).join("/")
Run Code Online (Sandbox Code Playgroud)