Gentlemen,
I posted a huge problem some time ago and I assume it was too long.
I made some examinations and I am pretty sure that it has the same roots as the situation I describe below.

PROBLEM
Let us have a program that uses QFtp to download some file.
This applies to the program below:
Qt Code:
  1. #ifndef FTPGET_H
  2. #define FTPGET_H
  3.  
  4. #include <QFile>
  5. #include <QFtp>
  6.  
  7. class QUrl;
  8.  
  9. class FtpGet : public QObject
  10. {
  11. Q_OBJECT
  12.  
  13. public:
  14. FtpGet(QObject *parent = 0);
  15.  
  16. bool getFile(const QUrl &url);
  17.  
  18. signals:
  19. void done();
  20.  
  21. private slots:
  22. void ftpDone(bool error);
  23.  
  24. private:
  25. QFtp ftp;
  26. QFile file;
  27. };
  28.  
  29. #endif
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include <QtCore>
  2. #include <QtNetwork>
  3. #include <iostream>
  4.  
  5. #include "ftpget.h"
  6.  
  7. using namespace std;
  8.  
  9. FtpGet::FtpGet(QObject *parent)
  10. : QObject(parent)
  11. {
  12. connect(&ftp, SIGNAL(done(bool)), this, SLOT(ftpDone(bool)));
  13. }
  14.  
  15. bool FtpGet::getFile(const QUrl &url)
  16. {
  17. if (!url.isValid()) {
  18. cerr << "Error: Invalid URL" << endl;
  19. return false;
  20. }
  21.  
  22. if (url.scheme() != "ftp") {
  23. cerr << "Error: URL must start with 'ftp:'" << endl;
  24. return false;
  25. }
  26.  
  27. if (url.path().isEmpty()) {
  28. cerr << "Error: URL has no path" << endl;
  29. return false;
  30. }
  31.  
  32. QString localFileName = QFileInfo(url.path()).fileName();
  33. if (localFileName.isEmpty())
  34. localFileName = "ftpget.out";
  35.  
  36. file.setFileName(localFileName);
  37. if (!file.open(QIODevice::WriteOnly)) {
  38. cerr << "Error: Cannot open " << qPrintable(file.fileName())
  39. << " for writing: " << qPrintable(file.errorString())
  40. << endl;
  41. return false;
  42. }
  43.  
  44. ftp.connectToHost(url.host(), url.port(21));
  45. ftp.login();
  46. ftp.get(url.path(), &file);
  47. ftp.close();
  48. return true;
  49. }
  50.  
  51. void FtpGet::ftpDone(bool error)
  52. {
  53. if (error) {
  54. cerr << "Error: " << qPrintable(ftp.errorString()) << endl;
  55. } else {
  56. cerr << "File downloaded as " << qPrintable(file.fileName())
  57. << endl;
  58. }
  59. file.close();
  60. emit done();
  61. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. #include <QtCore>
  2. #include <iostream>
  3.  
  4. #include "ftpget.h"
  5.  
  6. using namespace std;
  7.  
  8. int main(int argc, char *argv[])
  9. {
  10. QCoreApplication app(argc, argv);
  11. QStringList args = app.arguments();
  12.  
  13. if (args.count() != 2) {
  14. cerr << "Usage: ftpget url" << endl
  15. << "Example:" << endl
  16. << " ftpget ftp://ftp.trolltech.com/mirrors" << endl;
  17. return 1;
  18. }
  19.  
  20. FtpGet getter;
  21. if (!getter.getFile(QUrl(args[1])))
  22. return 1;
  23.  
  24. QObject::connect(&getter, SIGNAL(done()), &app, SLOT(quit()));
  25.  
  26. return app.exec();
  27. }
To copy to clipboard, switch view to plain text mode 

This is an example application from one of the QT devoted books.

It runs smoothly when the user is on-line.

The problem arises when the user has some connection problems.
Try to run the application while off-line.
The console becomes blocked and it will be until we connect ourselves to web or kill the process.

My question:
How to make our application quit with a certain warning for example after 10 seconds of unsuccessful trials to connect to the web?

PS. I tried to use QFtp::abort() with QTimer but it did not work!