本文整理汇总了C++中QFileDialog::setDefaultSuffix方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileDialog::setDefaultSuffix方法的具体用法?C++ QFileDialog::setDefaultSuffix怎么用?C++ QFileDialog::setDefaultSuffix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileDialog
的用法示例。
在下文中一共展示了QFileDialog::setDefaultSuffix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: save_as
void MainWindow::save_as()
{
QFileDialog dialog;
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setDefaultSuffix("xml");
dialog.setNameFilter(tr("xml files (*.xml)"));
if (dialog.exec() == QDialog::Accepted)
{
this->filename = dialog.selectedFiles().at(0);
if (!this->save(this->filename))
{
this->filename = "";
QMessageBox message;
message.setText("Could not save the file.");
message.exec();
}
else // set the new window title
{
this->update_title();
this->change_happened = false; // reset the change watcher
}
}
}
示例3: save_clicked
void Main_win::save_clicked()
{
try
{
QFileDialog fd;
fd.setDefaultSuffix(".mat"); // not working under linux?!
QString q_form = fd.getSaveFileName(this, tr("Save Matrix"));
std::ofstream target(q_form.toStdString(), std::ios::trunc);
if(target.fail()) throw std::ios_base::failure("cannot save matrix");
for(int i = 0; i < mat_dim_.first; ++i)
{
for(int j = 0; j < mat_dim_.second; ++j)
{
auto item = qobject_cast< Field* >(ui_->mat_layout->itemAtPosition(i,
j)->widget());
if(item)
target << item->get_text() << " ";
}
target << "\n";
}
target.close();
}
catch(std::exception& e)
{
to_display(e.what());
}
}
示例4: onSaveChat
void MainWindow::onSaveChat()
{
QFileDialog * saveChatDialog = new QFileDialog(this, "Save chat", QString(), "*.html");
saveChatDialog->setAcceptMode(QFileDialog::AcceptSave);
saveChatDialog->setFileMode(QFileDialog::AnyFile);
saveChatDialog->setDefaultSuffix("html");
connect(saveChatDialog, SIGNAL(finished(int)), this, SLOT(onSaveChatFinished(int)));
saveChatDialog->show();
}
示例5: saveProject
void ProjectHandle::saveProject(){
if(this->projPath==""){
QFileDialog dlg;
dlg.setDefaultSuffix("fproj");
QString path = dlg.getSaveFileName(NULL,tr("Project location"), ".",tr("Project files (*.fproj)"));
if(path.isEmpty()){
return;
}
QFileInfo inf(path);
if(inf.suffix()!="fproj"){
QString tmp=inf.baseName();
tmp+=".fproj";
path=inf.absolutePath()+"/"+tmp;
}
this->projPath=path;
}
QFileInfo inf(projPath);
QDomDocument doc(inf.baseName());
QDomElement root = doc.createElement("Project");
doc.appendChild(root);
root.setAttribute("appVersion",version);
root.setAttribute("Name",projName);
QHash<QString,PObject>::iterator iter;
iter=projObjects.begin();
for(int i=0;i<projObjects.size();i++){
PObject tmp=iter.value();
QDomElement obj = doc.createElement("Object");
root.appendChild(obj);
obj.setAttribute("Path",tmp.path);
obj.setAttribute("Material",tmp.material);
obj.setAttribute("Height",tmp.height);
obj.setAttribute("Width",tmp.width);
iter++;
}
QFile pfile(projPath);
if(pfile.open(QIODevice::WriteOnly)){
QTextStream stream(&pfile);
stream << doc.toString();
pfile.close();
projName=inf.baseName();
}
}
示例6: saveAsMask
bool ImageViewer::saveAsMask(QString &pathMask)
{
if(_mask.empty()) 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("bmp");
if(fDlg->exec() == QDialog::Accepted)
{
QString filename = fDlg->selectedFiles()[0];
if(m_method == 0)
{
if(saveLabelMap(filename))
{
pathMask = filename;
return true;
}
else return false;
}
else
{
_mask = _mask * 255;
IplImage* temp = new IplImage(_mask);
QImage* temp2 = IplImageToQImage(temp);
if(temp2->save(filename))
{
pathMask = filename;
if(temp2) delete temp2;
return true;
}
else return false;
}
}
else
{
return true;
}
}
示例7: saveButtonClicked
void SyntroReview::saveButtonClicked(QAbstractButton *button)
{
QFileDialog *fileDialog;
if (m_CFSState != SYNTROREVIEW_CFS_STATE_OPEN)
return; // no open file anyway
if (button == m_saveFrame){
fileDialog = new QFileDialog(this, "JPEG (.jpg) file name");
fileDialog->setAcceptMode(QFileDialog::AcceptSave);
fileDialog->setFileMode(QFileDialog::AnyFile);
fileDialog->selectFile(m_saveFilePath);
fileDialog->setNameFilter("*.jpg");
fileDialog->setDefaultSuffix("jpg");
if (fileDialog->exec()) {
m_saveFilePath = fileDialog->selectedFiles().at(0);
saveCurrentFrame();
}
}
}
示例8: wizardFinished
void CalculationWizard::wizardFinished()
{
QFileDialog *fd = new QFileDialog ( this, tr ( "Select file for saving calculation results" ) );
fd->setDefaultSuffix ( ".txt" );
fd->setNameFilter ( "Text Documents (*.txt)" );
fd->setAcceptMode ( QFileDialog::AcceptSave );
if ( fd->exec() == true )
{
Data::UserInput input;
input.resultsFilePath = fd->selectedFiles().at ( 0 );
input.maximumValue = qobject_cast<WizardSettingsPage *> ( ui->wizard->wizardPages[0] )->getMaximumValue();
input.ipComparison = qobject_cast<WizardSettingsPage *> ( ui->wizard->wizardPages[0] )->getIpComparison();
input.log = qobject_cast<WizardSettingsPage *> ( ui->wizard->wizardPages[0] )->getLogarithmicBase();
input.maximumCalculations = qobject_cast<WizardAutoStopPage *> ( ui->wizard->wizardPages[2] )->getMaximumCalculations();
input.maximumCoincidences = qobject_cast<WizardAutoStopPage *> ( ui->wizard->wizardPages[2] )->getMaximumCoincidences();
input.extendedIpSearch = qobject_cast<WizardIpSearchPage *> ( ui->wizard->wizardPages[1] )->getExtendedIpSearch();
input.search = qobject_cast<WizardIpSearchPage *> ( ui->wizard->wizardPages[1] )->getIpSearch();
fd->deleteLater();
emit userInputCompleted ( input );
}
}
示例9: on_pushButton_clicked
void Results::on_pushButton_clicked()
{
QFileDialog *saveFileDialog = new QFileDialog(this,
tr("Export Data"), "", tr("Excel Import (*.csv)"));
saveFileDialog->setDefaultSuffix("csv");
saveFileDialog->setViewMode(QFileDialog::Detail);
if(saveFileDialog->exec())
{
QStringList fileName = saveFileDialog->selectedFiles();
FILE* file = fopen(fileName[0].toAscii().data(), "w");
fprintf(file, "Pn (kip),Mn (kip-ft),phi-Pn (kip),phi-Mn (kip-ft)\n");
for(int i = 0; i < data->graphCount; i++)
{
fprintf(file, "%lf,%lf,%lf,%lf\n",data->unfactoredPoints[i][0]/1000,data->unfactoredPoints[i][1]/1000/12,
data->factoredPoints[i][0]/1000, data->factoredPoints[i][1]/1000/12);
}
fclose(file);
}
delete saveFileDialog;
}
示例10: initializeImageFileDialog
static void initializeImageFileDialog(QFileDialog &dialog, QFileDialog::AcceptMode acceptMode)
{
static bool firstDialog = true;
if (firstDialog) {
firstDialog = false;
const QStringList picturesLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
dialog.setDirectory(picturesLocations.isEmpty() ? QDir::currentPath() : picturesLocations.last());
}
QStringList mimeTypeFilters;
const QByteArrayList supportedMimeTypes = acceptMode == QFileDialog::AcceptOpen
? QImageReader::supportedMimeTypes() : QImageWriter::supportedMimeTypes();
foreach (const QByteArray &mimeTypeName, supportedMimeTypes)
mimeTypeFilters.append(mimeTypeName);
mimeTypeFilters.sort();
dialog.setMimeTypeFilters(mimeTypeFilters);
dialog.selectMimeTypeFilter("image/jpeg");
if (acceptMode == QFileDialog::AcceptSave)
dialog.setDefaultSuffix("jpg");
}
示例11: on_actionOpen_triggered
void MainWindow::on_actionOpen_triggered()
{
QFileDialog dialog;
QString selected_file;
dialog.setAcceptMode(QFileDialog::AcceptOpen);
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setDefaultSuffix("xml");
dialog.setNameFilter(tr("xml files (*.xml)"));
if (dialog.exec() == QDialog::Accepted)
{
selected_file = dialog.selectedFiles().at(0);
if (!this->closing_file()) // prompt the user
return;
this->load(selected_file);
this->update_graphics();
}
}
示例12: saveImage
void GLWidget::saveImage() {
rgbImage temp;
if ( rb!=0 ) {
rb->lockRead();
int idx=rb->curRead();
FrameData * frame = rb->getPointer ( idx );
VisualizationFrame * vis_frame=(VisualizationFrame *)(frame->map.get("vis_frame"));
if (vis_frame !=0 && vis_frame->valid) {
temp.copy ( vis_frame->data );
rb->unlockRead();
} else {
rb->unlockRead();
return;
}
}
if ( temp.getWidth() > 1 && temp.getHeight() > 1 ) {
QFileDialog dialog ( this,
"Export image to file...",
"",
"PNG (*.png)" );
dialog.setConfirmOverwrite ( true );
dialog.setDefaultSuffix ( "png" );
dialog.setAcceptMode ( QFileDialog::AcceptSave );
if ( dialog.exec() ) {
if ( dialog.selectedFiles().size() > 0 ) {
QString filename=dialog.selectedFiles().at ( 0 );
if ( temp.save ( filename.toStdString() ) ) {
QMessageBox::information ( this, "Success","PNG was saved successfully." );
} else {
QMessageBox::warning ( this, "Error","Unknown error while saving PNG." );
}
}
}
}
}
示例13: newProject
void ProjectHandle::newProject(){
if(projPath!=""){
if(closeProject()==1) return;
}
QFileDialog dlg;
dlg.setDefaultSuffix("fproj");
QString path = dlg.getSaveFileName(NULL,tr("Project location"), ".",tr("Project files (*.fproj)"));
if(path.isEmpty()){
return;
}
QFileInfo inf(path);
if(inf.suffix()!="fproj"){
QString tmp=inf.baseName();
tmp+=".fproj";
path=inf.absolutePath()+"/"+tmp;
}
this->projPath=path;
QDomDocument doc("xml version=\"1.0\" encoding=\"UTF-8\"");
QDomElement root = doc.createElement(inf.baseName());
doc.appendChild(root);
root.setAttribute("appVersion",version);
QFile pfile(path);
if(pfile.open(QIODevice::WriteOnly)){
QTextStream stream(&pfile);
stream << doc.toString();
pfile.close();
projName=inf.baseName();
}
return;
}
示例14: on_actionOpen_triggered
/**
* Open existing database
*/
void BursarApp::on_actionOpen_triggered()
{
QString fileName;
QFileDialog dialog;
dialog.setDefaultSuffix("bdb");
fileName = dialog.getOpenFileName(NULL, tr("Open Database"), "", tr("Bursar Files (*.bdb);;All Files (*.*)"));
if (fileName != "") {
if (m_doc->openDatabase(fileName)) {
// create main window
//if (m_mainWindow != NULL) {
// m_mainWindow = new MainWindow(m_db);
// show main window
// m_mainWindow->show();
//} else {
// initialize main window
//m_mainWindow->init();
//}
}
}
}
示例15: addPlainTextTab
void ContentViewer::addPlainTextTab()
{
if(_entity->hasPlainText())
{
QWidget *plainTextTab=new QWidget(ui->tvFormats);
plainTextTab->setObjectName("Plain Text");
plainTextTab->setWindowTitle("Plain Text");
QVBoxLayout *plainTextTabLayout=new QVBoxLayout();
QPlainTextEdit *plainTextEdit=new QPlainTextEdit(plainTextTab);
plainTextEdit->setPlainText(_entity->plainText(false,-1));
plainTextEdit->setReadOnly(true);
plainTextTabLayout->addWidget(plainTextEdit);
QHBoxLayout *plainTextInfoLayout=new QHBoxLayout();
QLabel *plainTextInfoLabel=new QLabel(plainTextTab);
plainTextInfoLabel->setText(QString("<b>length :</b> %1").arg(plainTextEdit->toPlainText().count())
+" "+QString("<b>size :</b> %1 KB").arg((double)_entity->formatSize("text/plain")/1024));
plainTextInfoLayout->addWidget(plainTextInfoLabel);
QPushButton *btnExport=new QPushButton(plainTextTab);
connect(btnExport,&QPushButton::clicked,this,[this,plainTextEdit](){
QFileDialog dialog;
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setWindowTitle("select a file to save text");
dialog.setWindowIcon(QIcon(Resources::Export16));
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setDefaultSuffix("txt");
for(;;)
{
if(dialog.exec())
{
int length=dialog.selectedFiles().length();
if(length>0 && length==1)
{
QFile file(dialog.selectedFiles().at(0));
file.open(QIODevice::WriteOnly);
if(file.isWritable())
{
qint64 i= file.write(plainTextEdit->toPlainText().toUtf8());
if(i<0)
{
int messageResult= QMessageBox::critical(this,"cannot write to the file.","cannot write to the selected file.nothing saved. \ntry another file.",QMessageBox::Ok,QMessageBox::Cancel);
if(messageResult==QMessageBox::Ok)
continue;
else break;
}
else break;
}
else
{
int messageResult= QMessageBox::critical(this,"cannot write to the file.","cannot write selected file. \ntry another file.",QMessageBox::Ok,QMessageBox::Cancel);
if(messageResult==QMessageBox::Ok)
continue;
else break;
}
}
}
else break;
}
});
btnExport->setIcon(QIcon(Resources::Export16));
btnExport->setText("export");
plainTextInfoLayout->addStretch();
plainTextInfoLayout->addWidget(btnExport);
plainTextTabLayout->addLayout(plainTextInfoLayout);
plainTextTab->setLayout(plainTextTabLayout);
ui->tvFormats->addTab(plainTextTab,"Plain Text");
}
}