Results 1 to 9 of 9

Thread: Why does this not work?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Why does this not work?

    Quote Originally Posted by lnxusr View Post
    Well yeah, to those who know what they're doing.. ;/
    Or maybe to those that can read English

    I don't get the error the first time I used up top. Would thedownloadFinished(QNetworkReply*) slot not still be valid, or can you only use them once?
    I completly don't understand wha tou mean.


    I'm writing this app to learn not only QT, but C++ as well.
    If you want to learn QT you have to go to Appple forums. Here you can only learn Qt.

    It'll take me a while to get the hang of the OO world.
    OO has nothing to do with asynchronous execution.

    QT's documentation is not easy to follow if you don't know the basics of C++, but I'm still working on the app anyway.
    You should really learn C++ first before taking on Qt. You'll save yourself lots of time.

    By the way, if all you wanted was to save the download to a file, you might have done it in much shorter code.

    Qt Code:
    1. QHttp *http = new QHttp(this);
    2. http->setHost(...);
    3. QFile *file = new QFile("...");
    4. file->open(QFile::WriteOnly);
    5. http->get("...", file);
    To copy to clipboard, switch view to plain text mode 
    And that's it.

    Alternatively with QNetworkAccessManager:
    Qt Code:
    1. QNetworkReply *reply = manager->get(...);
    2. connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(saveToFile(QNetworkReply*)));
    3. //...
    4. void ThisClass::saveToFile(QNetworkReply *reply) {
    5. QFile f(...);
    6. f.open(...);
    7. f.write(reply->readAll());
    8. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 17th December 2009 at 08:44.
    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.


  2. The following user says thank you to wysota for this useful post:

    lnxusr (17th December 2009)

  3. #2
    Join Date
    Nov 2009
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    3

    Default Re: Why does this not work?

    Quote Originally Posted by wysota View Post
    I completly don't understand wha tou mean.
    In my original post. The first statement of the gethtfile class is

    Qt Code:
    1. connect(&manager, SIGNAL(finished(QNetworkReply*)),
    2. SLOT(downloadFinished(QNetworkReply*)));
    To copy to clipboard, switch view to plain text mode 

    I don't get an the warning message from this, but did when I connect again in the event loop in doDownload.

    You should really learn C++ first before taking on Qt. You'll save yourself lots of time.
    I know, but until I get the books I ordered, I'll still play around with my app. I have nothing else to work on right now, and it fills my free time. It may be frustrating, but I am slowly figuring things out. Like I said before, things work, but it's nowhere near usable. It's more of a hodge podge of classes and functions for testing and seeing how things work. I don't know if you can really call it an app or not. I'll most likely start from scratch or rewrite 95% of what I've done, but I am learning a few things.

    While searching the forums, I see alot of people saying QHttp is depreciated and to use QNetworkManager. That's why I moved away from it. It sounds like, in the future (5.0?) Qt will do away with QHttp.

    By the way, if all you wanted was to save the download to a file, you might have done it in much shorter code.
    Thanks for the snippets, I'll add them to my notes..

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

    Default Re: Why does this not work?

    Quote Originally Posted by lnxusr View Post
    I have nothing else to work on right now, and it fills my free time.
    I suggest reading these:
    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. #4
    Join Date
    Nov 2009
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    3

    Default Re: Why does this not work?

    Great! Thanks wysota,

    I read the preface and scanned through the first volume last night. Looks pretty well organized, and I think it may be just what I need. Awesome reviews on Amazon as well. I may see about getting hard copies from Abebooks.

    The second volume has some macro's in it. I have OpenOffice set to disable macros, are they required to use the book? Also not sure if word macros will work properly in OOo.

Similar Threads

  1. Making MySQL plugin work on a windows x86 enviroment
    By Baasie in forum Installation and Deployment
    Replies: 1
    Last Post: 2nd September 2009, 15:15
  2. getting MySQL to work with Qt
    By Ashish in forum Installation and Deployment
    Replies: 7
    Last Post: 19th May 2009, 08:57
  3. Qt4 : QPainter::setRedirected doesn't work
    By Ankitha Varsha in forum Qt Programming
    Replies: 2
    Last Post: 20th June 2008, 17:52
  4. QActions don't work with menubar hidden
    By Pepe in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2007, 01:04
  5. Change work area OS
    By pakulo in forum Qt Programming
    Replies: 15
    Last Post: 15th May 2007, 07:20

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
  •  
Qt is a trademark of The Qt Company.