QTQuick(QML)中的FileDialog:以给定名称保存文件 [英] FileDialog in QTQuick (QML): Save file under given name
问题描述
我们正在构建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
-
QtQuick.Dialogs中的
-
FileDialog:无法设置文件名
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()进行的本地对话框:在快速应用程序中,没有用于父级"的QWidget.
Native dialog via static QFileDialog::getSaveFileName(): in Quick application there is no QWidget available for 'parent'
QT对话框:模态无效,因为未设置'parent'.在快速应用程序中,没有QWidget可用于setParent()调用
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
(将C ++与QT 5.1和QtQuick 2.1一起使用,包括所有桌面组件)
(Using C++ with QT 5.1 and QtQuick 2.1 incl. all desktop components)
推荐答案
此博客文章涵盖了整个问题,并提供了可能的解决方案: QML中的高级FileDialog(以指定名称保存文件)
This blog post covers the whole problem and provides a possible solution: Advanced FileDialog in QML (Save file under given name)
这篇关于QTQuick(QML)中的FileDialog:以给定名称保存文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!