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()); } }
void SpriteSceneConverter::exportar() { QSettings settings("toglia3d","SpriteSceneConverter"); QString rutaExportar = settings.value("rutaExportar", QString("/home")).toString(); QFileDialog saveDialog; saveDialog.confirmOverwrite(); QString ruta = saveDialog.getSaveFileName( this, tr("Exportar archivo"), rutaExportar, tr("*.xml"), QFileDialog::ShowDirsOnly & QFileDialog::HideNameFilterDetails ); if(!rutaCargarArchivo.isEmpty()) { QSettings settings("toglia3d","SpriteSceneConverter"); settings.setValue("rutaExportar", ruta); if(!ruta.endsWith(".2ds")) { ruta = ruta+".2ds"; } escribirXml(ruta, mModelo); } }
void smallPictureView::saveAs(){ if(!allImgs.isEmpty()){ QFileDialog *fileDialog = new QFileDialog(this);//创建一个QFileDialog对象,构造函数中的参数可以有所添加。 fileDialog->setWindowTitle(tr("Save As"));//设置文件保存对话框的标题 fileDialog->setAcceptMode(QFileDialog::AcceptSave);//设置文件对话框为保存模式 fileDialog->setFileMode(QFileDialog::AnyFile);//设置文件对话框弹出的时候显示任何文件,不论是文件夹还是文件 fileDialog->setViewMode(QFileDialog::Detail);//文件以详细的形式显示,显示文件名,大小,创建日期等信息; QString filename = fileDialog->getSaveFileName(this, tr("Save File"), "/home/wz/img/未命名.png", tr("Images (*.png)")); qDebug()<<filename<<currentfile; fileDialog->setGeometry(10,30,100,200);//设置文件对话框的显示位置 saveAsThread->saveAsFlag = 1; saveAsThread->breakNum = 1; if(!saveAsThread->allImgs.isEmpty()){ saveAsThread->allImgs.clear(); } saveAsThread->allImgs = allImgs; saveAsThread->imgNum = imgNum; saveAsThread->filename = filename; saveAsThread->selectedNum = selectedNum; saveAsThread->start(); }else{ QMessageBox message(QMessageBox::NoIcon, "提示", "请先选择图片文件!"); message.setIconPixmap(QPixmap("../2.png")); message.exec(); } }
void MainWindow::on_actionSave_triggered() { QFileDialog dlg; dlg.setAcceptMode(QFileDialog::AcceptSave); QString fileName = dlg.getSaveFileName(); qDebug() << fileName; result->save(fileName); }
void QSimTestGUI::SaveScenario(QString filename){ if(filename.isEmpty()){ QFileDialog f; filename = f.getSaveFileName(0,"Save State",QDir::home().absolutePath(),""); } if(!filename.isNull()){ string str = filename.toStdString(); SendCommand("save_state",str); old_filename=filename; } }
void CRunGui::saveHistStats() { QFileDialog saveHistDlg; saveHistDlg.setFilter("Text files (*.csv)"); saveHistDlg.setFilter("All files (*.*)"); ActualFN = saveHistDlg.getSaveFileName(this); if (ActualFN.isEmpty())return; ActualFN=ActualFN.left(ActualFN.lastIndexOf("."))+".csv"; if (Env.Statist.SaveActHistStatist(ActualFN.toAscii().data(),Env.Time,&Env.Grid)) statusBar()->showMessage(tr("Histogram statistics saved.")); else statusBar()->showMessage(tr("Histogram statistics were not saved.")); }
void CRunGui::saveTimeStats() { QFileDialog saveAggrDlg; saveAggrDlg.setFilter("Text files (*.csv)"); saveAggrDlg.setFilter("All files (*.*)"); ActualFN = saveAggrDlg.getSaveFileName(this); if (ActualFN.isEmpty())return; ActualFN=ActualFN.left(ActualFN.lastIndexOf("."))+".csv"; if (Env.Statist.SaveTimeStatist_InColumnsAppend(ActualFN.toAscii().data())) statusBar()->showMessage(tr("Time statistics saved.")); else statusBar()->showMessage(tr("Time statistics were not saved.")); }
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(); } }
void MainWindow::saveFile() { QFileDialog dialog (this); dialog.setFilter("Text files (*.txt)"); QString filename; if (dialog.exec() == QDialog::Accepted) { filename = dialog.getSaveFileName(); QFile f( filename ); f.open( QIODevice::WriteOnly ); QTextStream out(&f); out << textEdit->toPlainText(); } }
void CRunGui::saveAggrStats() { QFileDialog saveAggrDlg; saveAggrDlg.setFilter("Text files (*.txt)"); saveAggrDlg.setFilter("All files (*.*)"); ActualFN = saveAggrDlg.getSaveFileName(this); if (ActualFN.isEmpty())return; ActualFN=ActualFN.left(ActualFN.lastIndexOf("."))+".txt"; Env.CountStatistics(); if (Env.Statist.SaveActAgrStatist(ActualFN.toAscii().data(),Env.Time)) statusBar()->showMessage(tr("Aggregated statistics saved.")); else statusBar()->showMessage(tr("Aggregated statistics were not saved.")); }
void QtHistoTfuncPixmap::save(void) { printf("QtHistoTfuncPixmap save()\n"); int i; QFileDialog* fd = new QFileDialog(this); QString fn = fd->getSaveFileName(currentworkingdir, "*.tf2", this ); if(fn.isEmpty()) return; //check the user entered the extension, otherwise add it to the filename if(fn[int(fn.length()-4)]!='.') fn += ".tfn"; if (fn.isEmpty()) return; ofstream fout; fout.open(fn.latin1()); fout<<"// Transfer Function File"<<endl<<endl; fout<<"//=========================================================="<<endl; fout<<"// Threshold levels:"<<endl; fout<<"// min, max"<<endl; fout<<"// int, int"<<endl; fout<<"//=========================================================="<<endl; fout<<"THRESHOLD_LEVELS"<<endl; fout<<minthr<<" "<<maxthr<<endl; fout<<"// Trasnfer Functions"<<endl; fout<<"// size, cp.x, cp.y, cp.z ....."<<endl; fout<<"// int, float, float, float ...."<<endl; fout<<"//=========================================================="<<endl; fout<<"TF_CONTROL_POINTS"<<endl; fout<<funceditor.bs.control_points.size()<<endl; for(i=0; i<funceditor.bs.control_points.size(); i++) { fout<<funceditor.bs.control_points[i].x<<" "<<funceditor.bs.control_points[i].y<<" "<<funceditor.bs.control_points[i].z<<endl; } fout<<endl; fout.close(); delete fd; }
////////////////////////////////////////////////////////////////////////////////// // This funciton is called when a puzzle needs to be saved to a text file. ////////////////////////////////////////////////////////////////////////////////// void MainController::onSavePuzzle(){ if(test) testfile << "MC22 ####################### MainController onSavePuzzle #######################\n"; QString filePath; QFileDialog* fileDialog = new QFileDialog(); filePath = fileDialog->getSaveFileName(&view, "Save file", "", "*.*"); if(filePath != "") { if(test) testfile << "MC23 FilePath is not empty\n"; puzzleSerializer.serialize(puzzle, filePath); } else{ if(test) testfile << "MC24 Filepath was empty\n"; //Popup error message... //TODO } }
void MainWindow::on_saveAsProjectAction_triggered() { QFileDialog * fileDialog = new QFileDialog(); fileDialog->setAcceptMode( QFileDialog::AcceptSave ); QString fileName = fileDialog->getSaveFileName( this, tr( "Save as a project" ), QString( boost::filesystem::initial_path().string().c_str() )); std::vector<std::string> strs; const std::string st = fileName.toStdString(); boost::split(strs, st, boost::is_any_of("/")); std::string nameFile = strs.back(); std::string nameFolder = ""; for(std::vector<std::string>::iterator it = strs.begin() ; it < strs.end()-1 ; ++it) nameFolder += "/" + (*it) ; project().setProjectFolder(nameFolder); project().setProjectFile(nameFile); on_saveProjectAction_triggered(); }
/*! \brief 新建工程目录 \fn CMainWindow::on_actionNew_triggered */ void CMainWindow::on_actionNew_triggered() { QFileDialog fileDialog; QString strProFilename = fileDialog.getSaveFileName(this, tr("Save file"), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), tr(""),0,QFileDialog::ShowDirsOnly); if (strProFilename.isEmpty()) { return; }else { qDebug()<<strProFilename; QDir dir(strProFilename); dir.mkdir(strProFilename); m_strProjectPath = strProFilename; emit signal_OpenProject(m_strProjectPath); this->setWindowTitle(m_strProjectPath); } }
void articleDialog::onSave() { QFileDialog fileDlg; QString filename = fileDlg.getSaveFileName(); if (!filename.isNull()) { QFile f(filename); if ((f.open(QIODevice::WriteOnly))) { f.write(strArticle.toLocal8Bit()); f.close(); } else { QMessageBox mb("Access file error:", filename, QMessageBox::Warning, 0, 0, 0, this, 0); mb.exec(); } } }
void FileController::saveDialogEnable() { QFileDialog sDialog; QString pathTmp = sDialog.getSaveFileName(0, tr("Сохранить файл как..."), "", tr("STuring files (*.stur)")); if(!pathTmp.isEmpty()) { lines.clear(); path = pathTmp; emit saveFileSign(); file = new QFile(path); QFileInfo info(*file); if(info.suffix().isEmpty()) { info.suffix() = ".stur"; } file->open(QIODevice::ReadWrite); emit sendPath(path); } }
void Q3ExternalPlot::on_savePlotButton_clicked() { QFileDialog *fileDialog = new QFileDialog(this); QString path = fileDialog->getSaveFileName(this, tr("Save as image"), "../data", tr("PNG file (*.png)")); if (path.isEmpty()) return; QFileInfo file(path); if (file.suffix().isEmpty()) path += ".png"; QImage img(ui->plotWidget->size(), QImage::Format_ARGB32); QPainter painter(&img); ui->plotWidget->render(&painter); img.save(path); }
//Guardar txt void MainWindow::saveAs() { QFileDialog dialog (this); QString fileName = dialog.getSaveFileName(this, tr("Guardar como..."), QString(), tr("TXT (*.txt)")); cout << fileName.toStdString() << endl; if (fileName.isEmpty()) return; if (!fileName.endsWith(".txt", Qt::CaseInsensitive)) fileName += ".txt"; QFile file (fileName); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { cout << "Error al abrir archivo modo escritura" << endl; return; } QTextStream stream (&file); stream << ui->textNormal->toPlainText(); }
QString fs::saveFileDialog(const QVariant &config){ QVariantMap conf = json->jsonParser(config).toVariantMap(); QString title = "Save File", path = this->homePath(), ext = ""; if(conf["title"].toString() != ""){ title = conf["title"].toString(); } if(conf["path"].toString() != ""){ path = conf["path"].toString(); } if(conf["type"].toString() != ""){ ext = conf["type"].toString(); } QFileDialog *fd = new QFileDialog; QWidget *widget = new QWidget(); QString directory = fd->getSaveFileName(widget, title,path,ext); return directory; }
void CRunGui::saveEnvAs()//pozor! tahle funkce ulozi jenom broucky - chybi: ulozit cas, kytky, statistiky. { QFileDialog saveDlg; //saveDlg.setFilter("Abeetles files (*.txt;*.bmp)"); //saveDlg.setFilter("All files (*.*)"); ActualFN = saveDlg.getSaveFileName(this,"Save Environment","","Abeetles files (*.abl)"); //1QMessage::information(NULL,"MyApp",ActualFN); if (ActualFN.isEmpty())return; //if the filename already contains the suffix, I want to remove it if ( (-1!=ActualFN.lastIndexOf("_btl.txt"))||(-1!=ActualFN.lastIndexOf("_flw.txt"))||(-1!=ActualFN.lastIndexOf("_map.bmp"))||(-1!=ActualFN.lastIndexOf("_tst.csv")) ) ActualFN=ActualFN.left(ActualFN.lastIndexOf("_")); else //otherwise I remove only the ending ActualFN=ActualFN.left(ActualFN.lastIndexOf(".")); //1QMessage::information(NULL,"MyApp",ActualFN); if (ActualFN.isEmpty())return; if (Env.SaveEnv(ActualFN.toAscii().data())) statusBar()->showMessage(tr("Environment saved.")); else statusBar()->showMessage(tr("Environment was not successfully saved.")); }
void MainWindow::teamFileSave(int TeamNumber) { statusBar()->message(tr("Saving team data file...")); QFileDialog *TempFileDialog = new QFileDialog; TempFileDialog->setMode(QFileDialog::Directory); QString FileName = TempFileDialog->getSaveFileName(0,0,this,0,0); if(!FileName.isEmpty()){ if(GABotDoc->saveTeamToFile(FileName,TeamNumber)){ if (TeamNumber) { statusBar()->message(tr("Saving team B to "+FileName+"."), 5000); }else { statusBar()->message(tr("Saving team A to "+FileName+"."), 5000); } }else{ QMessageBox::warning(this,tr("File saving error"),tr("You probably don't have enough space on disk or something.")); statusBar()->message(tr("Saving aborted"), 1000); } }else{ statusBar()->message(tr("Saving aborted"), 1000); } delete TempFileDialog; }
QString Zipper::getZipDestination(QString fileName) { /* * ask the user for destination ... start within existing location */ QString dstName = fileName; dstName = dstName.mid(0,dstName.lastIndexOf(".")); /* Enumerate user input until it's unique */ int num = 0; QString serial(""); if(QFile::exists(dstName+serial+".zip")) { do { num++; serial = QString("(%1)").arg(num); } while(QFile::exists(dstName+serial+".zip")); } QFileDialog dialog; QString afilter("Zip File (*.zip)"); QString dstPath = dialog.getSaveFileName(0, tr("Zip"), dstName+serial+".zip", afilter); return dstPath; }
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; }
QString fs::saveFileDialog(){ QFileDialog *fd = new QFileDialog; QString directory = fd->getSaveFileName(); return directory; }
void MainWindow::ChangeCommandedPathLogFile(){ QFileDialog f; QString openDir = ini->value("log_commanded_path_file","simtest_commanded_path_log.csv").toString(); QString filename = f.getSaveFileName(this,"Set commanded Path Log File",openDir,tr("CSV File (*.csv);;Any File (*)")); ini->setValue("log_commanded_path_file",QFileInfo(filename).absoluteFilePath()); }