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. How can i save my files in a specific directory ?
Forum Updated to NodeBB v4.3 + New Features

How can i save my files in a specific directory ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.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.
  • I Offline
    I Offline
    imene
    wrote on last edited by imene
    #1

    Hi everyone;

    What to change in this line of code to save my files in a specific directory ?

    auto filename = QFileDialog::getSaveFileName(this, "Save", QDir::rootPath(), "CSV File(*.csv)");

    4cfe4871-f54c-4783-baa4-215ee555d6da-image.png

    JonBJ 1 Reply Last reply
    0
    • I imene

      Hi everyone;

      What to change in this line of code to save my files in a specific directory ?

      auto filename = QFileDialog::getSaveFileName(this, "Save", QDir::rootPath(), "CSV File(*.csv)");

      4cfe4871-f54c-4783-baa4-215ee555d6da-image.png

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @imene
      The one named dir for which you are presently passing QDir::rootPath()?

      Note that this does not force the user to save in that directory, it starts them there but they could still navigate to a different directory if they want. Depends whether you have an absolute requirement.

      1 Reply Last reply
      1
      • I Offline
        I Offline
        imene
        wrote on last edited by
        #3

        @JonB ,
        That's the point i want to sugguest a default Directory, than the user is free to save where ever he wants.

        JonBJ 1 Reply Last reply
        0
        • I imene

          @JonB ,
          That's the point i want to sugguest a default Directory, than the user is free to save where ever he wants.

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by JonB
          #4

          @imene Then that's fine you have your answer.

          1 Reply Last reply
          0
          • I Offline
            I Offline
            imene
            wrote on last edited by
            #5

            @JonB sorry but i mean i want to sugguest path Directory not the default one that QDir::rootPath() lead to it.

            JonBJ 1 Reply Last reply
            0
            • I imene

              @JonB sorry but i mean i want to sugguest path Directory not the default one that QDir::rootPath() lead to it.

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by
              #6

              @imene
              Yes, exactly. And I answered. It's the dir parameter. Change passing QDir::rootPath() as the value for that, pass whatever directory you want instead. How much clearer than that to answer your question?

              1 Reply Last reply
              2
              • M Offline
                M Offline
                mchinand
                wrote on last edited by
                #7

                Additionally, while you can specify any directory you want with that parameter, the QStandardPaths class may be useful if you want to specify the user's Documents or Desktop (and others) folder.

                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