Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. May I have a "Create New File" Dialog analogous to QFileDialog::getSaveFileName()
Forum Updated to NodeBB v4.3 + New Features

May I have a "Create New File" Dialog analogous to QFileDialog::getSaveFileName()

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 7.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jzq740176597
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • IamSumitI Offline
      IamSumitI Offline
      IamSumit
      wrote on last edited by
      #2

      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.

      Be Cute

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jzq740176597
        wrote on last edited by
        #3

        [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?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #4

          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;
          @

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved