使用QFileDialog可以方便地调用当前系统的文件对话框:
(1)文件打开对话框
QStringgetOpenFileName ( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(), const QString & filter = QString(), QString * selectedFilter = 0, Options options = 0 )
示例:
QString fileName;
fileName = QFileDialog::getOpenFileName(this,
tr("Open Config"), "", tr("SCD Files (*.scd);; CID Files (*.cid)"));
if (!fileName.isNull())
{
//fileName即是选择的文件名
}
else
//点是的取消
(2)文件保存对话框
QStringgetSaveFileName ( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(), const QString & filter = QString(), QString * selectedFilter = 0, Options options = 0 )
示例:
QString fileName;