QML判斷操作系統,獲取可執行文件路徑

Component.onCompleted: {
        var exePath = Qt.application.arguments[0];
        if (Qt.platform.os === "windows" || Qt.platform.os==="winrt") {
            var appPath = exePath.substring(0,exePath.lastIndexOf('\\'))
            console.log("====================",appPath)
        }else{
            appPath = exePath.substring(0,exePath.lastIndexOf('/'))
            console.log("====================",appPath)
        }
    }

 

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