Qml 中的 FileDialog 在 Release 中不起作用 [英] FileDialog in Qml not working in Release

查看:72
本文介绍了Qml 中的 FileDialog 在 Release 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Qt Quick Control 2 进行项目.当我尝试在调试模式下运行我的软件时 FileDialog.qml 完美打开但是当我将它部署为发布模式时它不起作用.

I am working on project with Qt Quick Control 2. When I try to run my software in debug mode FileDialog.qml opens perfectly but when I deploy it as release mode it doesn't work.

这是我的代码:

import QtQuick 2.4 
import QtQuick.Window 2.2 
import QtQuick.Controls 1.3 
import QtQuick.Dialogs 1.0 

// File Dialog to browse 
FileDialog { 
    id: openDialog 
    title: "Please Select An Image" 
    folder: shortcuts.pictures 
    nameFilters: ["Image files (*.BMP)"] 
    modality: Qt.NonModal 
    selectExisting: true 

    /*
     * do my stuff
    */
}

推荐答案

这里是我的 Js 函数调用 FileBrowse.qml(参数中的文件).我在其他视图中调用此函数,如下所示:

Here it is my Js function that calls FileBrowse.qml (file in parameters). I call this function in other view like this :

JsCommonCall.openFileDialog("frameFileBrowse.qml",2)


function openFileDialog(file,
                        parentCalled) {
    _component = Qt.createComponent(file);
    _popUp = _component.createObject(windowsMain,  {"x": offsetPopUpCreate,
                                                    "y": offsetPopUpCreate,
                                                    "parentCall":parentCalled});
    if(_popUp !== null)
        _popUp.open()
}

这是我的文件浏览

import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Dialogs 1.0

// File Dialog to browse
FileDialog {
    id: openDialog
    title: "Please Select An Image"
    folder: shortcuts.home
    nameFilters: ["Image files (*.BMP)"]
    selectFolder: true 
    // variables 
    property int parentCall; 

    onAccepted: {
        imgCurrentCam1.source = openDialog.fileUrl;
        openDialog.close()
    }


    onRejected: {
        openDialog.close()
    }
}

这篇关于Qml 中的 FileDialog 在 Release 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆