Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [SOLVED] download file from link to phone memory using qt???

[SOLVED] download file from link to phone memory using qt???

Scheduled Pinned Locked Moved Mobile and Embedded
14 Posts 4 Posters 5.5k 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.
  • D Offline
    D Offline
    DenisKormalev
    wrote on last edited by
    #2

    I think that you can use same approaches as at desktop, why not? You have some path in phone filesystem, you have url. All is the same.

    P.S. Moved to more appropriate category.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TobbY
      wrote on last edited by
      #3

      can you provide how to save?? i dont know???

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DenisKormalev
        wrote on last edited by
        #4

        Read Qt Assistant about QNetworkAccessManager. I think it will help you.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          loladiro
          wrote on last edited by
          #5

          Use "QNetworkAccessManager":http://doc.qt.nokia.com/4.7/qnetworkaccessmanager.html . QNetworkReply inherits QIODevice and I think you should be able to go from there.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            TobbY
            wrote on last edited by
            #6

            sorry it does nt help me where to save??? any other option

            1 Reply Last reply
            0
            • L Offline
              L Offline
              loladiro
              wrote on last edited by
              #7

              Not tested, but:
              @
              class MyClass : public QObject
              {
              Q_OBJECT
              public:
              MyClass(QObject *parent = 0) : QObject(parent), manager(new QNetworkAccessManager)
              {
              reply = manager->get(QNetworkRequest(QUrl("http://example.com")));
              connect(reply,SIGNAL(finished()),SLOT(downloaded()));
              }

              public slots:
              void downloaded()
              {
              QFile file("/path/to/file");
              file.open(QIODevice::WriteOnly);
              file.write(reply.readAll());
              file.close();
              }

              private:
              QNetworkAccessManager *manager;
              QNetworkReply *reply;
              }
              @

              EDIT: fixed example

              1 Reply Last reply
              0
              • T Offline
                T Offline
                TobbY
                wrote on last edited by
                #8

                have to tried it to download file larger than 2 MB.???

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  loladiro
                  wrote on last edited by
                  #9

                  Yes, I just did. Works like a charm :)

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    TobbY
                    wrote on last edited by
                    #10

                    yes, it works great, now i am trying to add progressbar to show how much download is completed.

                    have you any idea??

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      DenisKormalev
                      wrote on last edited by
                      #11

                      Use QProgressDialog or implement one by yourself. Qt Assitant and Qt examples contain all info that you need. Try to use them.

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        TobbY
                        wrote on last edited by
                        #12

                        thanks for help

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          abcth134
                          wrote on last edited by
                          #13

                          i insert this in the mainwindows.cpp:
                          @
                          MainWindow(QMainWindowparent = 0) : QMainWindow(parent), manager(new QNetworkAccessManager)
                          {
                          reply = manager->get(QNetworkRequest(QUrl("http://example.com")));
                          connect(reply,SIGNAL(finished()),SLOT(downloaded()));
                          }
                          @
                          and i get an error: C:\Users\zanotti\aaa-build-desktop..\aaa\mainwindow.cpp:29: error: expected ')' before '=' token

                          1 Reply Last reply
                          0
                          • L Offline
                            L Offline
                            loladiro
                            wrote on last edited by
                            #14

                            It should be more like:
                            @MainWindow::MainWindow(QWidget *parent = 0) : QMainWindow(parent), manager(new QNetworkAccessManager)
                            {
                            reply = manager->get(QNetworkRequest(QUrl("http://example.com")));
                            connect(reply,SIGNAL(finished()),SLOT(downloaded()));
                            }@

                            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