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

 

你可能感兴趣的:(QT)