Download and Download Manager Examples in Qt documentation
-
for this example,from the Qt documentation , http://qt-project.org/doc/qt-4.8/network-download.html the program first read all data to the buffer ,then all data are written to the disk from the buffer ,right ?
then for this example,from the Qt documentation , http://qt-project.org/doc/qt-4.8/network-downloadmanager.html the program is reading and writing data all the time ,right ?
and which way is more proper ?
-
In general there is no right or wrong.
It depends on your application and what you try to achieve. Sometimes it good to load all data into a buffer, but for another application, this might be completely wrong. Especially desktops have lots of memory available. Therefore, programmers tend to read everything into buffers without thinking too much about the consequences. A GB of memory is cheap today. However, when you like to run for instance your application on embedded device it still does matter. You might not have the possibility to simply allocate the GB and stuff the data into.
Personally, my limits are nowadays typically in MBs until thinking putting chucks to store.