本文整理汇总了C++中QFileDialog::setDirectory方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileDialog::setDirectory方法的具体用法?C++ QFileDialog::setDirectory怎么用?C++ QFileDialog::setDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileDialog
的用法示例。
在下文中一共展示了QFileDialog::setDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenWAVFile
void MainWindow::OpenWAVFile()
{
QFileDialog *g = new QFileDialog(this);
#if QT_VERSION==0x040806 || defined(Q_OS_UNIX)
g->setNameFilter("Audio Files (*.wav | *.mp3)");
#else
g->setNameFilter("Audio Files (*.wav;*.mp3)");
#endif
#if QT_VERSION>=0x050000 && !defined(Q_OS_UNIX)
g->setDirectory(lastdirR);
#endif
if(g->exec())
{
ui->listWidget->clear();
f = fopen(g->selectedFiles().at(0).toLocal8Bit().constData(),"rb");
fread(&format,1,44,f);
fclose(f);
ui->locut->setMaximum(format.SampleRate/2);
ui->hicut->setMaximum(format.SampleRate/2);
ui->locutslider->setMaximum(format.SampleRate/2);
ui->hicutslider->setMaximum(format.SampleRate/2);
filename = g->selectedFiles().at(0);
QFileInfo info(g->selectedFiles().at(0));
lastdirR = info.absolutePath();
ui->actionApply_Effect->setEnabled(true);
ui->pushButton->setEnabled(true);
}
}
示例2: saveAsLabelledResult
bool ImageViewer::saveAsLabelledResult(QString &pathResult)
{
if(!_srcOcvImage) return false;
if(!_displayImage) return false;
if(!_result_display) return false;
QFileDialog *fDlg = new QFileDialog(this);
fDlg->setWindowTitle(tr("保存标注结果"));
fDlg->setAcceptMode(QFileDialog::AcceptSave);
fDlg->setFileMode(QFileDialog::AnyFile);
fDlg->setViewMode(QFileDialog::Detail);
fDlg->setDirectory(QDir::currentPath());
fDlg->setFilter(MOLI_IMAGE_FILTER);
fDlg->setDefaultSuffix("png");
if(fDlg->exec() == QDialog::Accepted)
{
QString filename = fDlg->selectedFiles()[0];
if(_result_display->save(filename))
{
pathResult = filename;
return true;
}
else return false;
}
else return true;
}
示例3: on_saveDebugInfoButton_clicked
/**
* @brief Stores the debug information to a markdown file
*/
void SettingsDialog::on_saveDebugInfoButton_clicked() {
QFileDialog dialog;
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setDirectory(QDir::homePath());
dialog.setNameFilter(tr("Markdown files (*.md)"));
dialog.setWindowTitle(tr("Save debug information"));
dialog.selectFile("QOwnNotes Debug Information.md");
int ret = dialog.exec();
if (ret == QDialog::Accepted) {
QStringList fileNames = dialog.selectedFiles();
if (fileNames.size() == 0) {
return;
}
QFile file(fileNames.at(0));
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
qWarning() << file.errorString();
return;
}
QTextStream out(&file);
out.setCodec("UTF-8");
out << ui->debugInfoTextEdit->toPlainText();
file.flush();
file.close();
}
}
示例4: selectAssetDir
void ZoneViewerWindow::selectAssetDir()
{
QFileDialog fd;
fd.setFileMode(QFileDialog::Directory);
fd.setDirectory(m_scene->assetPath());
fd.setWindowTitle("Select an asset directory");
// OpenGL rendering interferes wtih QFileDialog
m_viewport->setAnimation(false);
if((fd.exec() == QDialog::Accepted) && (fd.selectedFiles().count() > 0))
m_scene->setAssetPath(fd.selectedFiles().value(0));
m_viewport->setAnimation(true);
}
示例5: on_readBtn_clicked
void codecs::on_readBtn_clicked()
{
QFileDialog *dialog = new QFileDialog();
dialog->setDirectory(curDir);
dialog->setWindowTitle("Open *any* file to decode if possible");
readFileToBuffer(dialog->getOpenFileName());
}
示例6: onBrowse
/**
Handler for the onbrowse event.
*/
void SlicingAlgorithmDialog::onBrowse() {
QFileDialog dialog;
dialog.setDirectory(QDir::homePath());
dialog.setNameFilter("Nexus files (*.nxs)");
if (dialog.exec()) {
ui.txt_filename->setText(dialog.selectedFiles().front());
}
}
示例7: browseMount
void Settings::browseMount() {
QFileDialog *fd = new QFileDialog(this);
fd->setFileMode(QFileDialog::DirectoryOnly);
fd->setAcceptMode(QFileDialog::AcceptOpen);
fd->setDirectory( txtMount->text() );
if (fd->exec())
txtMount->setText( fd->selectedFiles()[0] );
}
示例8: choosePath
void MainWindow::choosePath() {
QFileDialog dirDialog;
dirDialog.setFileMode(QFileDialog::DirectoryOnly);
dirDialog.setDirectory(ui->lineEdit_3->text());
if(dirDialog.exec()) {
if(!dirDialog.selectedFiles().isEmpty())
ui->lineEdit_3->setText(dirDialog.selectedFiles().at(0));
}
}
示例9: OpenDir
void BrowsePicture::OpenDir()
{
QFileDialog *fileDialog = new QFileDialog(this);
fileDialog->setWindowTitle(tr("选择图片所在文件夹路径"));
fileDialog->setDirectory("../");
fileDialog-> setFileMode( QFileDialog::DirectoryOnly );
if(fileDialog->exec() == QDialog::Accepted) {
pic_path = fileDialog->selectedFiles()[0];
}
}
示例10: on_btnSelectOutputFolder_clicked
void MainWindow::on_btnSelectOutputFolder_clicked() {
QFileDialog fileDlg;
fileDlg.setOption(QFileDialog::ShowDirsOnly, true);
fileDlg.setFileMode(QFileDialog::DirectoryOnly);
fileDlg.setDirectory(ui->txtOutpuFolder->text());
if (fileDlg.exec()) {
ui->txtOutpuFolder->setText(fileDlg.selectedFiles().at(0));
AppSettings::setOutputFolder(ui->txtOutpuFolder->text());
}
}
示例11: slotBrowseFlow
void PreferencesDialog::slotBrowseFlow()
{
QFileDialog dialog;
dialog.setAcceptMode(QFileDialog::AcceptOpen);
dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setDirectory(QFileInfo(ui->buildFlow->text()).absolutePath());
if (dialog.exec() == QDialog::Accepted) {
ui->buildFlow->setText(dialog.selectedFiles().at(0));
slotValidateFlowBinary();
}
}
示例12: showDirDialog
void CategoryDialog::showDirDialog()
{
QFileDialog *dlg = new QFileDialog(this);
dlg->setDirectory(ui->catpath->text());
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->setFileMode(QFileDialog::DirectoryOnly);
dlg->setWindowTitle(tr("Выбор директории"));
dlg->setOption(QFileDialog::DontUseNativeDialog);
dlg->setModal(true);
connect(dlg,SIGNAL(fileSelected(QString)),this,SLOT(setCategoryDir(QString)));
dlg->show();
}
示例13: on_btnSelectOutputDirectory_clicked
void MainWindow::on_btnSelectOutputDirectory_clicked()
{
QFileDialog fileDlg;
fileDlg.setOption(QFileDialog::ShowDirsOnly, true);
fileDlg.setFileMode(QFileDialog::DirectoryOnly);
fileDlg.setDirectory(ui->txtOutputDirectory->text());
if (fileDlg.exec())
{
ui->txtOutputDirectory->setText(fileDlg.selectedFiles().at(0));
QSettings().setValue("outputDirectory", ui->txtOutputDirectory->text());
}
}
示例14: open
/**
* @brief MainWindow::open
* Open new Mesh File
*/
void MainWindow::open(){
QFileDialog *fd;
QString filter;
fd = new QFileDialog();
fd->setDirectory(sampleDir);
FileName = fd->getOpenFileName(this,tr("Open Mesh Files"),sampleDir,"Mesh Files ( *.ply)", &filter);
if (!FileName.isEmpty()){
ui->glwidget->setMeshFile(FileName.toStdString());
ui->glwidget->initialize();
}
}
示例15: OpenFile
void MainWindow::OpenFile(void){
QFileDialog *fd;
QString filter;
fd = new QFileDialog();
fd->setDirectory(sampleDir);
FileName = fd->getOpenFileName(this,tr("Open Mesh Files"),sampleDir,"Mesh Files ( *.ply)", &filter);
if (!FileName.isEmpty()){
glwidget->setMeshFile(FileName);
glwidget->loadMesh();
}
}