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. Qt download example
Qt 6.11 is out! See what's new in the release blog

Qt download example

Scheduled Pinned Locked Moved Solved General and Desktop
qt 5.10.1
3 Posts 2 Posters 1.1k 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.
  • J Offline
    J Offline
    Jedd
    wrote on last edited by
    #1

    http://doc.qt.io/qt-5/qtnetwork-download-main-cpp.html

    Can this be converted to a function for an existing project? I'm struggling with how to do so. It works great as a standalone program.

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

      Hi
      Yes, it should be reusable without much fuss. except, make sure to place the class definitionsin a .h file
      as sample uses trick to get the moc tool (to allow for signals) to process the .CPP file.
      So best to include in a .h instead for reuse.
      Then there is the scope thing to be aware of.

      in sample, it does

      int main(int argc, char **argv)
      {
          QCoreApplication app(argc, argv);
      
          DownloadManager manager;
          QTimer::singleShot(0, &manager, SLOT(execute()));
      
          app.exec();
      }
      

      This you cannot directly use in function as manager will run out of scope and die so you have to new it.

          DownloadManager *manager = new DownloadManager(this);
          QTimer::singleShot(0, manager, SLOT(execute()));
      

      Else please tell what is causing issues so we can help.

      1 Reply Last reply
      5
      • J Offline
        J Offline
        Jedd
        wrote on last edited by
        #3

        Thank you for the help.

        1 Reply Last reply
        2

        • Login

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