gpt4 book ai didi

qt - 为 FileDialog 设置默认起始目录

转载 作者:行者123 更新时间:2023-12-02 00:56:15 24 4
gpt4 key购买 nike

我试图在 QtQuick 中为 FileDialog 设置默认起始目录,但它不起作用(意味着它总是打开可执行文件的目录):

property url defPath : "/home/saeid/Work/data";

FileDialog {
id:dialogPosPath;
selectFolder: true;
title: "Please select folder";
folder: defPath;
//rest of stuff

但是如果我将文件夹属性设置为例如folder:shortcuts.home 它工作正常!我不明白为什么。

documentation说:

The path to the currently selected folder. Setting this property before invoking open() will cause the file browser to be initially positioned on the specified folder.

The value of this property is also updated after the dialog is closed.

By default, the url is empty.

知道如何实现吗?

最佳答案

你应该使用 file scheme :

"file:///home/saeid/work/data"

关于qt - 为 FileDialog 设置默认起始目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34822641/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com