×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    13

    Error: "TypeError: Result of expression ... [undefined] is not a function" ?

    Hi everyone,

    I'm new in Qt programming. I'm trying to make a qt quick "download from an URL" program.

    This is what i did:
    - I created an DownPage.qml with a button so when I click the button it will download from a link.

    - I created an DownPage C class (downpage.cpp and downpage.h) base on this example:
    http://www.java2s.com/Code/Cpp/Qt/DownloadfromURL.htm

    - In my
    downpage.h:
    ...
    public slots:
    void downloadFinished(QNetworkReply *reply);
    void doDownload(const QUrl &url);
    ...



    downpage.cpp:
    ...
    void DownPage::doDownload(const QUrl &url)
    {
    qDebug()<<"haha"; // Just for test
    reply = manager.get(QNetworkRequest(url));
    downloadFinished(reply);
    }
    ...



    main.cpp:
    ...
    qmlRegisterType<DownPage>("Dow",1,0,"DownPage");
    ...



    DownPage.qml:
    ...
    onClicked: {
    DownPage.doDownload(link);
    }
    ...


    And when i click, the error appears "TypeError: Result of expression 'DownPage.doDownload' [undefined] is not a function.".
    Another question: How can I set directory for the download file?

    Pls help me! thanks
    Last edited by allicius; 2012-05-09 at 04:55.

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Error: "TypeError: Result of expression ... [undefined] is not a function" ?

    Hello allcius,

    I will recommend you not to use this way to download stuffs from QML code. Instead use Javascripts XMLHTTPRequest class , which i fairly simple to use

    Simple example

    Code:
        function getExample()
        {
            var request = new XMLHttpRequest();
            request.open('GET', 'http://www.mozilla.org/', true);
            request.send(null);
    
            if (request.status === 200) {
              console.log(request.responseText);
            }else{
                console.log("Error Occured")
            }
    
        }

  3. #3
    Registered User
    Join Date
    Apr 2012
    Posts
    13

    Red face Re: Error: "TypeError: Result of expression ... [undefined] is not a function" ?

    Hi gaba88,

    I will try it, thank for the help

  4. #4
    Registered User
    Join Date
    Apr 2012
    Posts
    13

    Re: Error: "TypeError: Result of expression ... [undefined] is not a function" ?

    Hi gaba88,

    Please help me one more time. When I try your code, this error appear: "Error: Invalid state". The error stop in line : if(request.status ===200). I try to search on internet but this line seem right.

    So maybe qt simulator haven't connected to internet yet or something ?

    Thanks!
    Last edited by allicius; 2012-05-09 at 11:52.

Similar Threads

  1. Replies: 2
    Last Post: 2011-11-18, 05:58
  2. Replies: 6
    Last Post: 2011-04-14, 12:56
  3. Replies: 3
    Last Post: 2010-09-30, 11:06
  4. Undefined Reference to "function name"
    By ragu. in forum Symbian
    Replies: 6
    Last Post: 2010-09-29, 08:00
  5. Replies: 0
    Last Post: 2006-08-25, 07:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×