Is there QPath::Combine in QT4?

前端 未结 3 1391
既然无缘
既然无缘 2021-02-13 15:28

I need a similar to .NET method for safely combining path parts without worrying for platform specifics of the path separator.

Is there such class and method in QT4?

3条回答
  •  独厮守ぢ
    2021-02-13 16:04

    I don't know of anything exactly like that, but you can get close by using QDir::cd():

    QDir path("base_path");
    path.cd("subdir");
    

    Unfortunately, I think that only works for directories, not files. For files, you could use QDir::filePath():

    QDir path("base_path");
    QString file_path = path.filePath("file.txt");
    

提交回复
热议问题