QFileDialog:如何设置选项以在getExistingDirectory()中显示文件夹的内容 [英] QFileDialog : how to set option to show content of folder in getExistingDirectory()

查看:2655
本文介绍了QFileDialog:如何设置选项以在getExistingDirectory()中显示文件夹的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将QFileDialog用作

filename = QFileDialog::getExistingDirectory(this,"Select Image File: ",dataDir,0);

我希望我可以在选择文件夹之前检查其中的文件.函数getExistingDirectory()QFileDialog::ShowDirsOnly设置为默认选项.我在docs中检查了没有与此相反的选项.因此,我将最后一个参数设置为0.但是现在它不使用本机对话框.我想与此使用本机对话框.我不知道如何执行此操作,因为在UseNativeDialog的选项中找不到标志.请帮忙.

I want that I can check files inside folder before selecting it. function getExistingDirectory() is setting QFileDialog::ShowDirsOnly as a default option. I checked in docs there is no any option that do opposite of this. So I set last parameter 0. But now it is not using native dialog. I want to use native dialog with this. I have no clue how to do this cause no flag found in options for UseNativeDialog. Please help.

推荐答案

塞巴斯蒂安(Sebastian)的代码应创建一个本机对话框,除非您进行如下一行:

The code by Sebastian should create a native dialog, unless you make a line such as:

dialog.setOption(QFileDialog::DontUseNativeDialog, true);

但是,即使文档说QFileDialog::Directory选项默认情况下应该显示文件,我也无法在Windows下运行该文件.不仅如此,而且还可以:

However, I have not been able to get this working under Windows, even though the documentation says that the QFileDialog::Directory option should display files by default. Not only that, but doing:

qDebug() << dir_selector.testOption(QFileDialog::ShowDirsOnly);

在我的系统上显示为false,表明某处可能存在错误.

displays false on my system, indicating that there is probably a bug somewhere.

这篇关于QFileDialog:如何设置选项以在getExistingDirectory()中显示文件夹的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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