How can I get a network filename without QFiledialog::getopenfilename()?
-
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. -
Hi,
What did you try and what doesn't work (or how does it fail) ?
-
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.
-
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.
-
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.