本文整理汇总了C++中QFileDialog::getSaveFileName方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileDialog::getSaveFileName方法的具体用法?C++ QFileDialog::getSaveFileName怎么用?C++ QFileDialog::getSaveFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileDialog
的用法示例。
在下文中一共展示了QFileDialog::getSaveFileName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
}
示例2: exportar
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);
}
}
示例3: saveAs
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();
}
}
示例4: on_actionSave_triggered
void MainWindow::on_actionSave_triggered()
{
QFileDialog dlg;
dlg.setAcceptMode(QFileDialog::AcceptSave);
QString fileName = dlg.getSaveFileName();
qDebug() << fileName;
result->save(fileName);
}
示例5: SaveScenario
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;
}
}
示例6: saveHistStats
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."));
}
示例7: saveTimeStats
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."));
}
示例8: 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();
}
}
示例9: saveFile
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();
}
}
示例10: saveAggrStats
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."));
}
示例11: save
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;
}
示例12: onSavePuzzle
//////////////////////////////////////////////////////////////////////////////////
// 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
}
}
示例13: on_saveAsProjectAction_triggered
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();
}
示例14: on_actionNew_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);
}
}
示例15: onSave
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();
}
}
}