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. File download - How to open the file?
QtWS25 Last Chance

File download - How to open the file?

Scheduled Pinned Locked Moved Unsolved General and Desktop
downloadqfile
2 Posts 2 Posters 917 Views
  • 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.
  • M Offline
    M Offline
    Mathan M
    wrote on 11 Oct 2016, 09:22 last edited by p3c0 10 Nov 2016, 09:24
    #1

    Hi,

    I am trying to download the file from the server through QML. I created an file called abc.tpk and map the path for file response.But I am getting an error stating:

    additionalMessage: The file path to the response file could not be opened.

    Query: Do we need to pen the file through QML like file.open in CPP. If it is the case, how to open the file in QML.

     QString filenamep = "Prefecture.tpk";
     QFile file(filenamep);
    
     file.open(QIODevice::WriteOnly);
     if(!file.open(QIODevice::WriteOnly))
     {
    
     }
    QString strUrl="http://testser/home/item.html?id=83d1c9aaf9d04e60bda3e822f25a8c67";
       QUrl url = QUrl::fromUserInput(strUrl);
    
       QFileInfo fileInfo(url.path());
      // QString strhost = url.encodedHost();
       QString filename = fileInfo.fileName();
    
       file.setFileName("C:\\Qt\\QHttp\\"+filename);
       http.setHost(url.host(),url.port(80));
       http.get(url.path(),&file);
    
    
       file.write(http.readAll());
       http.close();
    
        file.close();
    
    C 1 Reply Last reply 11 Oct 2016, 09:31
    0
    • M Mathan M
      11 Oct 2016, 09:22

      Hi,

      I am trying to download the file from the server through QML. I created an file called abc.tpk and map the path for file response.But I am getting an error stating:

      additionalMessage: The file path to the response file could not be opened.

      Query: Do we need to pen the file through QML like file.open in CPP. If it is the case, how to open the file in QML.

       QString filenamep = "Prefecture.tpk";
       QFile file(filenamep);
      
       file.open(QIODevice::WriteOnly);
       if(!file.open(QIODevice::WriteOnly))
       {
      
       }
      QString strUrl="http://testser/home/item.html?id=83d1c9aaf9d04e60bda3e822f25a8c67";
         QUrl url = QUrl::fromUserInput(strUrl);
      
         QFileInfo fileInfo(url.path());
        // QString strhost = url.encodedHost();
         QString filename = fileInfo.fileName();
      
         file.setFileName("C:\\Qt\\QHttp\\"+filename);
         http.setHost(url.host(),url.port(80));
         http.get(url.path(),&file);
      
      
         file.write(http.readAll());
         http.close();
      
          file.close();
      
      C Offline
      C Offline
      CharlieG
      wrote on 11 Oct 2016, 09:31 last edited by
      #2

      Hi @Mathan-M,

      With QML you can use Qt.openUrlExternally(/path/to/my/file/myFile) to open an file with the default program.
      More informations here.

      Bye

      Charlie

      1 Reply Last reply
      2

      2/2

      11 Oct 2016, 09:31

      • Login

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