QFileDialog :: DontUseNativeDialog不起作用 [英] QFileDialog::DontUseNativeDialog is not working

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

问题描述

我对一个简单的程序有疑问. 我这样打开QFileDialog:

I have an issue with a simple program. I'm opening a QFileDialog this way:

QFileDialog fileDialog(this);
fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
if (!fileDialog.exec())
return;

但是,它显示的是Qt对话框而不是本机Windows对话框.我使用的是Windows 7 x64,我确实更喜欢本机对话框而不是Qt对话框,因为它看起来有点花哨.但是,我已阅读并发现可以使用以下方法来更改它:

However it shows a Qt dialog instead the native Windows dialog. I'm using Windows 7 x64 and I really do preferr the native dialog instead of Qt dialog because it is a lil' bit more fancy. However I've read and I found that this can be changed by using:

fileDialog.setOption(QFileDialog::DontUseNativeDialog, false);

事实是我没有获得本机Windows对话框,而是获得了Qt对话框,因此该选项不起作用...有人知道如何在不使用静态成员的情况下解决此问题吗?

The fact is that I'm not getting the native Windows dialog but the Qt one, so that option is not working... Anyone knows how to solve this issue without using the static members?

我并不是真的想使用静态成员,因为它们有某种内存泄漏问题或其他原因,因为如果您反复使用静态成员打开新对话框,则程序所使用的内存会增加和增加.以前使用指针存储的对话框没有此问题.

I don't really want to use the static members because they have a kind of memory leak problem or something because if you open repeatedly new dialogs with the static member the memory used by your program increases and increases, however, using the dialog previously stored with a pointer doesn't have this problem.

所以,如果有人对此有一个答案(本机对话框和内存泄漏问题),请告诉我.

So, if someone has an answer about this both things (Native dialog and memory leak problem) plz tell me.

谢谢.

推荐答案

本机对话框不支持QFileDialog类公开的全部功能.这就是为什么只能通过称为getOpenFileName()getSaveFileName()等的静态快捷功能使用它们的原因.如果您正在使用这些功能,但仍然不想看到本机对话框,请使用DontUseNativeDialog标志.

The native dialogs don't support the full array of features exposed by the QFileDialog class. That's why they are only available through the static short-cut functions called getOpenFileName(), getSaveFileName() etc'. If you're using these functions and still don't want to see the native dialog, you use the DontUseNativeDialog flag.

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

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