May I have a "Create New File" Dialog analogous to QFileDialog::getSaveFileName()
-
like title above, I have tried to use @QFileDialog::getSaveFileName() instead,but the button name "save" not "New",And I don't find any interface to change it.
I just need a dialog to create a new file located somewhere, allowed user to select directory and input the name with specified extend ,may prompt for the Duplicate.
-
Hi.
Yes you can.@
QFileDialog dialog;
dialog.setFileMode(QFileDialog::AnyFile);
QString strFile = dialog.getSaveFileName(NULL, "Create New File","","");
//qDebug()<<strFile;
QFile file(strFile);
file.open(QIODevice::WriteOnly);
file.close();
@hope this helps.
-
[quote author="IamSumit" date="1413438781"]Hi.
Yes you can.@
QFileDialog dialog;
dialog.setFileMode(QFileDialog::AnyFile);
QString strFile = dialog.getSaveFileName(NULL, "Create New File","","");
//qDebug()<<strFile;
QFile file(strFile);
file.open(QIODevice::WriteOnly);
file.close();
@hope this helps.[/quote]
thanks for you reply,but I need "New" button not the "Save" button ,any hint?
-
According to the doc there is a "setLabelText":http://qt-project.org/doc/qt-5/qfiledialog.html#setLabelText method that allows to overwrite the labels.
@
QFileDialog* fileDialog = new QFileDialog;
fileDialog->setLabelText(QFileDialog::Accept, "Yes, please");
fileDialog->setLabelText(QFileDialog::Reject, "NOOOOO, thank you");
fileDialog->exec();
delete fileDialog;
@