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的路徑

 

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