Results 1 to 13 of 13

Thread: HTTP pause download in QTCreator

  1. #1
    Join Date
    Mar 2010
    Posts
    92
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default HTTP pause download in QTCreator

    i want create program download have pause download,can you help me ?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: HTTP pause download in QTCreator


  3. #3
    Join Date
    Nov 2010
    Posts
    47
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default

    This example does not work since Qt 4.2: http://www.qtcentre.org/threads/1020...314#post167314

    Have You tried it at least once? Does it work for You???
    Last edited by wysota; 28th November 2010 at 23:27. Reason: Merged two identical posts

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: HTTP pause download in QTCreator

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Reimplement QTcpSocket to limit download speed ???

    and the documentation explains why and how to still make it do what you want: http://labs.qt.nokia.com/2006/09/11/...vice-in-qt-42/

  6. #6
    Join Date
    Nov 2010
    Posts
    47
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Reimplement QTcpSocket to limit download speed ???

    Yes, explains. But it was not enough for me. I took Qt Torrent example, removed all torrent relative code from PeerWireClient (renamed it to KTcpSocket) as I need only tcp socket with rate control. But the program does not work at all. May I ask You to look at the code, please, where is the cause. Code attached. RateController class works just fine, checked, think the problem is in modified PeerWireClient class (my class name is KTcpSocket).
    Attached Files Attached Files

  7. #7
    Join Date
    Nov 2010
    Posts
    47
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: HTTP pause download in QTCreator

    I Saw this: http://www.qtcentre.org/threads/1020...314#post167314

    I took Qt Torrent example, removed all torrent relative code from PeerWireClient (renamed it to KTcpSocket) as I need only tcp socket with rate control. But the program does not work at all. May I ask You to look at the code, please, where is the cause. Code attached. RateController class works just fine, checked, think the problem is in modified PeerWireClient class (my class name is KTcpSocket).
    Attached Files Attached Files

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: HTTP pause download in QTCreator

    How does "does not work at all" manifest itself?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Nov 2010
    Posts
    47
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: HTTP pause download in QTCreator

    http://doc.trolltech.com/qq/qq17-ratecontrol.html example after fixes gets web page partially and outputs it to stdout. Same program but with PeerWireClient (without or with Torrent code) as socket class does nothing. No output at all.

  10. #10
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: HTTP pause download in QTCreator

    If one class works just fine and another class does not, why not just use the class which works fine?

    How does PeerWireClient work? Is it similar to rate control?

    (Surely you understand how the class works before trying to use it?)

  11. #11
    Join Date
    Nov 2010
    Posts
    47
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: HTTP pause download in QTCreator

    I tried to take PeerWireClient without modifications: does not work also as regular QTcpSocket.

    Qt Code:
    1. #include "ratecontroller.h"
    2. #include "peerwireclient.h"
    3.  
    4. #include <QtCore/QCoreApplication>
    5. #include <QtCore/QDebug>
    6.  
    7. class Foo : public QObject
    8. {
    9. Q_OBJECT
    10. public slots:
    11. void showData()
    12. {
    13. PeerWireClient *socket = (RcTcpSocket *)sender();
    14. //QTcpSocket *socket = (QTcpSocket *)sender();
    15. while (socket->canReadLine())
    16. qDebug() << socket->readLine();
    17. }
    18.  
    19. void onExit()
    20. {
    21. PeerWireClient *socket = (PeerWireClient *)sender();
    22. qDebug() << "bytesAvailable: " << socket->bytesAvailable();
    23. qDebug() << "socketBytesAvailable: " << socket->socketBytesAvailable();
    24. qDebug() << "canReadLine: " << socket->canReadLine();
    25. qDebug() << "socketCanReadLine: " << socket->QTcpSocket::canReadLine();
    26. }
    27. };
    28.  
    29. int main(int argc, char **argv)
    30. {
    31. QCoreApplication app(argc, argv);
    32.  
    33. RateController controller;
    34. controller.setUploadLimit(100);
    35. controller.setDownloadLimit(100);
    36.  
    37. PeerWireClient socket;
    38. controller.addSocket(&PeerWireClient);
    39. socket.connectToHost("qt.nokia.com", 80);
    40.  
    41. Foo foo;
    42.  
    43. QObject::connect(&socket, SIGNAL(readyRead()), &foo, SLOT(showData()));
    44. QObject::connect(&socket, SIGNAL(readChannelFinished()), &foo, SLOT(onExit()));
    45. //QObject::connect(&socket, SIGNAL(readChannelFinished()), &app, SLOT(exit()));
    46.  
    47. socket.write("GET / HTTP/1.0\r\n\r\n");
    48. return app.exec();
    49. }
    50.  
    51. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

    Have You ever tried to test or use either qq17-ratecontrol.html example or Torrent example? Or ever implemented QTcpSocket with speed limitation feature?

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: HTTP pause download in QTCreator

    Sorry but the code you posted will not even compile.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Nov 2010
    Posts
    47
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Talking Re: HTTP pause download in QTCreator

    I've found something: in Qt torrent example readLine functions was missed cause they were unnecessary for torrent. I added them to my KTcpSocket class definition (former PeerWireClient class):

    Qt Code:
    1. QByteArray readLine (qint64 maxSize = 0) { return socket.readLine(maxSize); }
    2. qint64 readLine(char *data, qint64 maxSize) { return socket.readLine(data, maxSize); }
    To copy to clipboard, switch view to plain text mode 

    And this is naturally and understandable because real data is sent QTcpSocket socket class member for which KTcpSocket acts as proxy. Now KTcpSocket instance receives data correctly but there is no traffic throttling, because socket's readyRead() signlal connected to readyRead() proxy signal. It is like endless cycle. Do not know what to do now??? However output traffic throttling should work (do not know how to test it for now).

    wysota, sorry for the code: probably put wrong archive here. Re-attached modified version (should compile).
    Attached Files Attached Files
    Last edited by AlekseyK; 29th November 2010 at 14:32.

Similar Threads

  1. Opensource Downloader can pause download
    By nhs_0702 in forum Qt Programming
    Replies: 0
    Last Post: 15th April 2010, 17:35
  2. Download via HTTP in several threads?
    By bjilly in forum Qt Programming
    Replies: 6
    Last Post: 30th November 2009, 14:15
  3. I need a pause (QTimer)
    By baray98 in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2008, 05:37
  4. Replies: 1
    Last Post: 14th June 2007, 15:52
  5. Pause executing QProcess
    By bravetanveer in forum Qt Programming
    Replies: 1
    Last Post: 3rd December 2006, 07:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.