本文整理汇总了C++中QFileDialog::selectedFile方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileDialog::selectedFile方法的具体用法?C++ QFileDialog::selectedFile怎么用?C++ QFileDialog::selectedFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileDialog
的用法示例。
在下文中一共展示了QFileDialog::selectedFile方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setFile
void SettingsDialog::setFile( QLineEdit *le, const QString &caption )
{
QFileDialog *fd = new QFileDialog( this );
fd->setCaption( caption );
fd->setMode( QFileDialog::AnyFile );
fd->setDir( QDir::homeDirPath() );
if ( fd->exec() == QDialog::Accepted ) {
if ( !fd->selectedFile().isEmpty() )
le->setText( fd->selectedFile() );
}
}
示例2: promptForFileName
void CDPWizard::promptForFileName(QLineEdit * theLineEdit, QString theShortName, QString theLongName)
{
QSettings myQSettings;
QString myFilterList;
FileReader::getGdalDriverMap(myFilterList);
QString myWorkDirString = myQSettings.readEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Dir",QDir::homeDirPath());
std::cout << "Filter List: " << myFilterList << std::endl;
QString myFileNameQString;
QFileDialog myFileDialog (myWorkDirString,myFilterList,0,"Select " + theLongName ,"Select " + theLongName);
QString myLastFilter = myQSettings.readEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Filter","");
if (!myLastFilter.isEmpty())
{
myFileDialog.setSelectedFilter(myLastFilter);
}
if ( myFileDialog.exec() == QDialog::Accepted )
{
myFileNameQString = myFileDialog.selectedFile();
theLineEdit->setText(myFileNameQString);
QFileInfo myFileInfo(myFileNameQString);
myQSettings.writeEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Dir",myFileInfo.dirPath());
myQSettings.writeEntry("/qgis/cdpwizard/DefaultDirectories/" + theShortName + "Filter",myFileDialog.selectedFilter());
checkInputFilenames();
}
}
示例3: file
void
WaveMaker::loadFile()
{
QFileDialog* fd = new QFileDialog(this, "Wave Maker Input File", TRUE);
fd->setMode(QFileDialog::AnyFile);
fd->setViewMode(QFileDialog::Detail);
QString fileName;
if (fd->exec() == QDialog::Accepted)
{
fileName = fd->selectedFile();
printf("Loading new file: %s\n", fileName.latin1());
setComment("File Name", fileName);
wave.clear();
QFile file(fileName);
if (file.open(IO_ReadOnly))
{
QTextStream stream(&file);
double value;
while (!stream.atEnd())
{
stream >> value;
wave.push_back(value);
}
filename = fileName;
}
示例4: openImage
void ossimQtSingleImageWindow::openImage()
{
QString caption = "iview : open image";
QString directory;
if (!theLastOpenedDirectory.empty())
{
if (theLastOpenedDirectory.exists())
{
directory = theLastOpenedDirectory.c_str();
}
}
QFileDialog* fd = new QFileDialog( this, caption, directory );
fd->setFileMode( QFileDialog::ExistingFile );
ossimFilename fileName;
if ( fd->exec() == QDialog::Accepted )
{
fileName = fd->selectedFile().ascii();
theLastOpenedDirectory = fileName.path();
}
delete fd;
fd = 0;
if (fileName.empty())
{
return;
}
displayImage(fileName);
}
示例5: pbtnOutputPath_clicked
void CDPWizard::pbtnOutputPath_clicked()
{
QSettings myQSettings;
QString myLastDir = myQSettings.readEntry("/qgis/cdpwizard/DefaultDirectories/OutputDir",QDir::homeDirPath());
QString myFileNameQString;
QFileDialog myFileDialog (myLastDir,"",this,"Select Output Directory");
myFileDialog.setMode(QFileDialog::DirectoryOnly);
if ( myFileDialog.exec() == QDialog::Accepted )
{
myFileNameQString = myFileDialog.selectedFile();
leOutputPath->setText(myFileNameQString);
myQSettings.writeEntry("/qgis/cdpwizard/DefaultDirectories/OutputDir",myFileNameQString);
}
}
示例6: chooseBackgroundImage
void VCWidget::chooseBackgroundImage()
{
QLCImagePreview* preview = new QLCImagePreview();
QFileDialog* fd = new QFileDialog(this);
fd->setContentsPreviewEnabled(true);
fd->setContentsPreview(preview, preview);
fd->setPreviewMode(QFileDialog::Contents);
fd->setFilter("Images (*.png *.xpm *.jpg *.gif)");
fd->setSelection(backgroundImage());
if (fd->exec() == QDialog::Accepted)
setBackgroundImage(fd->selectedFile());
delete preview;
delete fd;
}
示例7: getOpenFileName
QString View::getOpenFileName()
{
static QString workingDirectory = QDir::currentDirPath();
QFileDialog *dlg = new QFileDialog( workingDirectory,
QString::null, 0, 0, TRUE );
dlg->setCaption( QFileDialog::tr( "Open" ) );
dlg->setMode( QFileDialog::ExistingFile );
QString result;
if ( dlg->exec() == QDialog::Accepted ) {
result = dlg->selectedFile();
workingDirectory = dlg->url();
}
delete dlg;
return result;
}
示例8: addDirectoryClicked
void ossimQtElevationManagerDialog::addDirectoryClicked()
{
if (!theController) return;
QFileDialog* fd = new QFileDialog( this );
fd->setMode(QFileDialog::DirectoryOnly);
fd->setDir(ossimQtElevationManagerController::getLatestOpenCellPath().c_str());
QString directory;
if (fd->exec() == QDialog::Accepted )
{
directory = fd->selectedFile();
theController->onAddDirectory(directory);
}
// Delete fd???
delete fd;
fd = NULL;
}
示例9: saveSpecFilePushButtonClicked
void ossimQtIgenDialog::saveSpecFilePushButtonClicked()
{
if (theController)
{
QFileDialog* fd = new QFileDialog( this );
fd->setMode(QFileDialog::AnyFile);
fd->setDir(ossimQtIgenController::getLatestOutputFilePath().c_str());
QString file;
if (fd->exec() == QDialog::Accepted )
{
file = fd->selectedFile();
theController->saveSpecFile(file);
}
// Delete fd???
delete fd;
fd = NULL;
}
}
示例10: outputImageClicked
void ossimQtIcpDialog::outputImageClicked()
{
if (!theOutputImageField)
{
return;
}
QFileDialog* fd = new QFileDialog( this, "file dialog", TRUE );
fd->setMode( QFileDialog::AnyFile );
QString fileName;
if ( fd->exec() == QDialog::Accepted )
{
fileName = fd->selectedFile();
}
delete fd;
fd = NULL;
if (fileName.isEmpty())
{
return;
}
// Make sure output filename is not the same as input.
QString source_file = getImageFileName();
if (source_file == fileName)
{
QString caption = "Sorry:";
QString text = "Output file cannot be the same as input file.";
QMessageBox::information( this,
caption,
text,
QMessageBox::Ok );
theOutputImageField->setText("");
return;
}
theOutputImageField->setText(fileName);
}
示例11: execExportFileDialog
void FLJasperEngine::execExportFileDialog(const QString &defaultFileName,
const QString &defaultFormat)
{
bool multiLang = aqApp->multiLangEnabled();
aqApp->setMultiLang(false);
QFileDialog *fd = new QFileDialog(0, "aq_execExportFileDialog", true);
fd->setMode(QFileDialog::AnyFile);
fd->setFilters(QStringList()
<< "Pdf"
<< "Csv"
<< "Docx"
<< "EmbeddedImagesXml"
<< "Html"
<< "MultipleSheetsXls"
<< "Odt"
<< "Rtf"
<< "SingleSheetXls"
<< "Xml");
setDefaultExportFormat(defaultFormat);
fd->setSelectedFilter(d->defaultExportFormat());
fd->setSelection(defaultFileName);
fd->setCaption(tr("Exportar Informe a..."));
connect(fd, SIGNAL(filterSelected(const QString &)),
this, SLOT(setDefaultExportFormat(const QString &)));
if (fd->exec() == QDialog::Accepted) {
QString outFile(fd->selectedFile());
if (!outFile.isEmpty())
exportReportToFile(outFile, d->defaultExportFormat());
}
delete fd;
aqApp->setMultiLang(multiLang);
}
示例12: educe
void ZhscWidget::educe()
{
if ( !bConStatus )
{
return;
}
uint len = 0;
uint index = 0;
int n = 0;
QString tmp;
QChar c( 0x2028 );
tePoem->setTextFormat( Qt::PlainText );
teMemo->setTextFormat( Qt::PlainText );
tePoet->setTextFormat( Qt::PlainText );
tmp = tePoem->text() + "\n" + teMemo->text() + "\n" + tePoet->text();
tePoem->setTextFormat( Qt::AutoText );
teMemo->setTextFormat( Qt::AutoText );
tePoet->setTextFormat( Qt::AutoText );
len = tmp.length();
while ( 1 )
{
n = tmp.find( c, index );
if ( n < 0 )
break;
tmp.replace( n, 1, "\n" );
index = n;
}
QString sFileName;
QFileDialog *fd = new QFileDialog( this );
fd->setMode( QFileDialog::AnyFile );
fd->setFilter( Unicode( "所有文件 (*.*)" ) );
fd->setViewMode( QFileDialog::Detail );
fd->setCaption( Unicode( "中华诗词 Qt版" ) );
if ( fd->exec() == QDialog::Accepted )
{
sFileName = fd->selectedFile();
if ( QFile::exists( sFileName ) )
{
if ( QMessageBox::warning( NULL, Unicode( "中华诗词 Qt版" ),
Unicode( "这个文件已经存在,覆盖它?" ),
Unicode( "确定" ),
Unicode( "取消" ), 0, 0, 1 ) == 1)
{
delete fd;
return;
}
}
delete fd;
}
if ( sFileName != "" )
{
QFile f( sFileName );
if ( f.open( IO_WriteOnly | IO_Truncate ) )
{
QTextCodec *codec = new QGb18030Codec();
QTextStream ts( &f );
ts.setCodec( codec );
ts << tmp;
f.close();
}
}
return;
}