Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
772 views
in Technique[技术] by (71.8m points)

qt - QFileDialog::DontUseNativeDialog is not working

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;

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);

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.

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...