Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    I am a noob and I don't get how to input a value into this code and have it out put the value into a text edit? (Please Help me!)

    General and Desktop
    2
    2
    1041
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      MathSquare last edited by

      How to get the source code from a web page with this code @QNetworkReply * QNetworkAccessManager::get(const QNetworkRequest & request)@ and I don't get how to input a website like "http://www.fsf.org/" and input it into a text edit? If you are woundering where I get this code from is from where "http://qt-project.org/doc/qt-5.0/qtnetwork/qnetworkaccessmanager.html#get". I try this code but it doesn't work @#include <QNetworkAccessManager>
      //...Code between...
      //... button push...
      ui->textEdit->setText(QNetworkReply * QNetworkAccessManager::get(const QNetworkRequest & "http://www.fsf.org/"));
      @
      Please help me.

      1 Reply Last reply Reply Quote 0
      • D
        DerManu last edited by

        I recommend a C++ beginner's book or tutorial. Once you've got the C++ basics, you can start with Qt.

        @ QNetworkReply * QNetworkAccessManager::get(const QNetworkRequest & request)
        @
        Means that QNetworkAccessManager instances have a method called "get". Those get methods take an argument of type "QNetworkRequest" and return a pointer to a QNetworkReply.

        Just like any other natural language, programming must be learned, and doesn't work by just hacking together stuff you think might work :). You have four problems in your one code line:

        1. A string literal is not a QNetworkRequest.
        2. get is not a static method of QNetworkAccessManager.
        3. If you use the method (as opposed to declaring it), you don't write the return type in front, but rather use it, either by calling methods on it or assigning it to a variable of that type.
        4. QNetworkReply* is not a QString.
        1 Reply Last reply Reply Quote 0
        • First post
          Last post