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. QFile dialog to save a file
Forum Updated to NodeBB v4.3 + New Features

QFile dialog to save a file

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 355 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1
    QString path_file = QString("%1\\%2\\%3").arg(ROOT_ACQUISITION,cartella,text_file_da_copiare );
        QString path_nuovo= QString("%1\\%2").arg("C:\\cartella\\",nome_file);
        QDir dir;
    
        if (!dir.exists("C:\\cartella\\"))
    
        {
            dir.mkpath("C:\\cartella\\");
    
        }
    
    //    if (QFile::exists(path_file))
    //        QFile::remove(path_nuovo);
    
        //QFile::copy(path_file, path_nuovo);
    
        QList<QUrl> urls;
        urls << QUrl::fromLocalFile("C://Acquisizione");
        QFileDialog dialog;
        dialog.setSidebarUrls(urls);
        QFileDialog::getSaveFileName(&dialog,tr("Copia File"), path_file, tr("(*.txt)"), nullptr, QFileDialog::DontUseNativeDialog);
        dialog.exec();
    

    I have to save a file that I select but when I choice the path an other window opens and the file isn't saved

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      QFileDialog::getSaveFileName
      only gets a filename/path so it will not save anything for you.
      so you need some code to save data.

      ? 1 Reply Last reply
      2
      • mrjjM mrjj

        Hi
        QFileDialog::getSaveFileName
        only gets a filename/path so it will not save anything for you.
        so you need some code to save data.

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        @mrjj ok, so in this way I obtain the path that I choice to save?
        then I can use:

        QFile::copy(path_file, path_nuovo);

        mrjjM 1 Reply Last reply
        0
        • ? A Former User

          @mrjj ok, so in this way I obtain the path that I choice to save?
          then I can use:

          QFile::copy(path_file, path_nuovo);

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @vale88

          Yes. if the file you select should be copied to path_nuovo

          1 Reply Last reply
          1

          • Login

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