QFileDialog替代使用由操作系统定义的默认文件对话框? [英] QFileDialog alternative that uses default file dialog defined by OS?

查看:156
本文介绍了QFileDialog替代使用由操作系统定义的默认文件对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在我的程序中使用 QFileDialog ,但我更喜欢主机操作系统使用的默认文件对话框。在我的情况下,由于我使用Windows 7,它应该看起来像这样:

I tried using a QFileDialog in a program of mine, but I prefer the default file dialog that is used by the host's OS. In my case, since I use Windows 7, it should look like this:

有没有办法使Qt使用主机操作系统使用的默认文件对话框?

Is there a way to make Qt use the default file dialog that is used by the host's OS?

我的代码:

QFileDialog saveDialog(this);
saveDialog.setAcceptMode(QFileDialog::AcceptSave);

if (!saveDialog.exec())
    return;


推荐答案

使用静态函数,

QString filename = QFileDialog::getOpenFileName(this, ... vars);

它将使用OSX和Windows的本地对话框,但如果您不使用静态函数来显示它,它会使用QT一。

It will use the native dialogs for OSX and Windows, but if you don't use one of the static functions to show it, it will use the QT one.

它是写在文档中的那些不同的静态函数。

It was written in the docs for those different static functions.

http:// doc。 qt.io/qt-4.8/qfiledialog.html

这篇关于QFileDialog替代使用由操作系统定义的默认文件对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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