Results 1 to 2 of 2

Thread: work with web generated xml

  1. #1
    Join Date
    Nov 2008
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default work with web generated xml

    Hello,

    I need to work with web generated xml document. If I work with local disk file, everithing's fine:
    Qt Code:
    1. ...
    2. QFile file(url);
    3. if(!file.open(QFile::ReadOnly | QFile::Text)) {
    4. cout << "chyba!";
    5. return;
    6. }else{
    7. cout << "soubor otevren...";
    8. read(&file);
    9. }
    10. file.close();
    11. ...
    To copy to clipboard, switch view to plain text mode 

    You see, I send to method read pointer to file (QIODevice). I want to do something like this:
    Qt Code:
    1. ...
    2. QUrl address = QUrl(url);
    3.  
    4. if(!address.open(QFile::ReadOnly | QFile::Text)) {
    5. cout << "chyba!";
    6. return;
    7. }else{
    8. cout << "soubor otevren...";
    9. read(&address);
    10. }
    11. ...
    To copy to clipboard, switch view to plain text mode 
    Of course I know, it's wrong. I found only QDesktopServices:penUrl ( const QUrl & url ) but it opens URL in web browser and I don't want this! I need to work with generated xml file.

    It crossed my mind that I can save generated document to disk and then can I work with that like I want to. But I think it's soo complicated.

    Thx for any answer...

  2. #2
    Join Date
    Nov 2008
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: work with web generated xml

    Hello,

    can anyone help me, with my problem? I have this code:

    Qt Code:
    1. #include <iostream>
    2. #include <QApplication>
    3. #include <QIODevice>
    4. #include <QFile>
    5. #include <QTextStream>
    6. #include <QUrl>
    7. #include <QtNetwork>
    8. #include <QHttp>
    9. #include <QObject>
    10.  
    11. int main(int argc, char *argv[]){
    12. QCoreApplication app(argc, argv);
    13. QTextStream out(stdout);
    14. QHttp *http = new QHttp();
    15. QFile *file = new QFile("index.html");
    16. file->open(QIODevice::WriteOnly);
    17. http->setHost("www.trolltech.com");
    18. out << http->errorString() << endl;
    19. http->get(QUrl::toPercentEncoding("/index.html"), file);
    20. out << http->errorString() << endl;
    21. file->close();
    22. return 0;
    23. }
    To copy to clipboard, switch view to plain text mode 

    And the result is:

    Unknown error
    Unknown error


    I tried many different versions of code, but the result is still that Know anybody what can by wrong?

    Thx for all answers...

Similar Threads

  1. Qt4 : QPainter::setRedirected doesn't work
    By Ankitha Varsha in forum Qt Programming
    Replies: 2
    Last Post: 20th June 2008, 17:52
  2. QActions don't work with menubar hidden
    By Pepe in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2007, 01:04
  3. Change work area OS
    By pakulo in forum Qt Programming
    Replies: 15
    Last Post: 15th May 2007, 07:20

Tags for this Thread

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.