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 get a network filename without QFiledialog::getopenfilename()?

How can I get a network filename without QFiledialog::getopenfilename()?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.7k 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.
  • C Offline
    C Offline
    chenjie4255
    wrote on last edited by
    #1

    good morning boys, Now I meet a problem,I want to download a network file which's action look like QFileDialog::getOpenFileName(), for example , it will download a copy of file to the temp directory in windows, I has try QFile,but it doesn't work.
    PS: I wanted to get this file's name which is in a system temporary directory.
    thank you.

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

      Hi,

      What did you try and what doesn't work (or how does it fail) ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #3

        You can get temp directory with:
        @
        QString dir(QDesktopServices::storageLocation(QDesktopServices::TempLocation));
        @

        But your description of the problem is so unclear I'm not even sure what do you want. As SGaist said, we need more info to help you.

        (Z(:^

        1 Reply Last reply
        0
        • C Offline
          C Offline
          chenjie4255
          wrote on last edited by
          #4

          In MSVC, it has such a function name urldownloadtocachefile,while we use QFileDialog::getopenfilename to get a network file, it would call this function to do a downloading,so the QFileDialog::GetOpenFileName return a local file such as "C:\Users\D15133\AppData\Local\Temp....something."

          What I wanted to ask is :"Is Qt has a method to do something like MSVC's UrlDownloadtoCache?"

          thanks.

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            There is QTemporaryFile. Or you can simply use QDesktopServices I've told you about before. THen just pass that path to the code that does downloading for you.

            (Z(:^

            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