QT-系统路径、exe、相对路径

/**获取系统桌面路径
 * @time: 2019-7-5
 * @author: qiangu
 * @return: desktopPath
 */
QString FileDirectory::getDesktopPath(){

    QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
    qDebug()<< "desktopPath:" << desktopPath;
    return desktopPath;

}

/**获取的执行文件exe所在的路径
 * @time: 2019-7-5
 * @author: qiangu
 * @return: applicationDirPath
 */
QString FileDirectory::getApplicationDirPath(){

    // QString QApplication::applicationDirPath()
    QString applicationDirPath = QApplication::applicationDirPath();
    qDebug()<< "applicationDirPath:" << applicationDirPath;
    return applicationDirPath;

}

//相对路径,常用于资源文件。在QtCreater中的“./”这个路径是bulid directory的路径

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章