QTQuick (QML) 中的 FileDialog:以给定名称保存文件 [英] FileDialog in QTQuick (QML): Save file under given name

查看:28
本文介绍了QTQuick (QML) 中的 FileDialog:以给定名称保存文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在构建一个 Qt Quick 应用程序,它必须能够以给定名称保存文件.

We're building a Qt Quick app, that must be able to save a file under a given name.

FileDialog 组件中你只能设置一个目录.这对用户不太友好,因为您不想每次下载文件时都手动输入文件名.

In the FileDialog component you can only set a directory. This is not very user-friendly, since you don't want to type in a filename by hand every time you download a file.

到目前为止,我们尝试了不同的东西

So far we tried different things

  1. 来自 QtQuick.Dialogs 的 FileDialog:无法设置文件名

  1. FileDialog from QtQuick.Dialogs: filename cannot be set

通过 QPlatformFileDialogHelper 的本机对话框(顽皮的私有 c++ hack):无法在 Linux (Gnome) 上设置文件名

Native dialog via QPlatformFileDialogHelper (naughty private c++ hack): filename cannot be set on Linux (Gnome)

通过静态 QFileDialog::getSaveFileName() 的原生对话框:在 Quick 应用程序中没有可用于父级"的 QWidget

Native dialog via static QFileDialog::getSaveFileName(): in Quick application there is no QWidget available for 'parent'

通过 QFileDialog 实例的 QT 对话框:模式不起作用,因为未设置父级".在快速应用程序中,没有可用于 setParent() 调用的 QWidget

QT dialog via QFileDialog instance: Modality doeas not work, since 'parent' is not set. In Quick application there is no QWidget available for setParent() call

(在 QT 5.1 和 QtQuick 2.1 中使用 C++,包括所有桌面组件)

(Using C++ with QT 5.1 and QtQuick 2.1 incl. all desktop components)

推荐答案

这篇博文涵盖了整个问题并提供了一个可能的解决方案:QML 中的高级文件对话框(以给定名称保存文件)(RIP Kullo 博客)

This blog post covers the whole problem and provides a possible solution: Advanced FileDialog in QML (Save file under given name) (RIP Kullo blog)

实现该解决方案的存储库在这里:https://github.com/kullo/qml-file-dialog-demo

The repository implementing the solution is here: https://github.com/kullo/qml-file-dialog-demo

这篇关于QTQuick (QML) 中的 FileDialog:以给定名称保存文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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