Qt 打开文件对话框
2011-06-09 22:33
363 查看
http://hi.baidu.com/cybertingred/blog/item/28b5850098f3ae97e950cdfa.html
1.打开单个文件
QString filename = QFileDialog::getOpenFileName(
this,
"Open Document",
QDir::currentPath(),
"Document files (*.doc *.rtf);;All files(*.*)");
if (!filename.isNull()) { //用户选择了文件
// 处理文件
QMessageBox::information(this, "Document", "Has document", QMessageBox::Ok | QMessageBox::Cancel);
} else // 用户取消选择
QMessageBox::information(this, "Document", "No document", QMessageBox::Ok | QMessageBox::Cancel);
2. 可以选定多个文件的文件打开对话框
QFileDialog::Options options;
if (!native->isChecked())
options |= QFileDialog::DontUseNativeDialog;
QString selectedFilter;
QStringList files = QFileDialog::getOpenFileNames(
this, tr("QFileDialog::getOpenFileNames()"),
openFilesPath,
tr("All Files (*);;Text Files (*.txt)"),
&selectedFilter,
options);
if (files.count()) {
openFilesPath = files[0];
openFileNamesLabel->setText(QString("[%1]").arg(files.join(", ")));
}
1.打开单个文件
QString filename = QFileDialog::getOpenFileName(
this,
"Open Document",
QDir::currentPath(),
"Document files (*.doc *.rtf);;All files(*.*)");
if (!filename.isNull()) { //用户选择了文件
// 处理文件
QMessageBox::information(this, "Document", "Has document", QMessageBox::Ok | QMessageBox::Cancel);
} else // 用户取消选择
QMessageBox::information(this, "Document", "No document", QMessageBox::Ok | QMessageBox::Cancel);
2. 可以选定多个文件的文件打开对话框
QFileDialog::Options options;
if (!native->isChecked())
options |= QFileDialog::DontUseNativeDialog;
QString selectedFilter;
QStringList files = QFileDialog::getOpenFileNames(
this, tr("QFileDialog::getOpenFileNames()"),
openFilesPath,
tr("All Files (*);;Text Files (*.txt)"),
&selectedFilter,
options);
if (files.count()) {
openFilesPath = files[0];
openFileNamesLabel->setText(QString("[%1]").arg(files.join(", ")));
}
相关文章推荐
- qt中获取打开文件路径,颜色对话框,字体对话框,自定义对话框,消息对话框,输入对话框
- 利用Qt对话框选择文件打开路径
- QT 打开文件对话框总结
- Qt打开文件对话框同时选中多个文件
- Qt打开文件对话框
- QT打开文件对话框
- Qt中打开文件对话框和保存文件对话框
- QT 打开文件对话框
- QT打开和保存文件对话框
- python qt(pyqt)的文件打开、文件保存、文件夹选择对话框
- Qt打开文件对话框
- Qt打开文件对话框同时选中多个文件
- QT打开文件对话框和保存文件对话框介绍,以记事本为例
- QT打开文件对话框和保存文件对话框介绍,以记事本为列
- QT 打开文件对话框总结
- QT打开和保存文件对话框
- Qt入门-打开和保存文件对话框
- Qt 打开保存文件对话框
- QT设计UI:QT模式对话框打开文件
- QT 打开文件对话框总结