Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "widget.h"
- #include "ui_widget.h"
- Widget::Widget(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::Widget)
- {
- ui->setupUi(this);
- apiUrl = "http://www.forismatic.com/api/1.0/";
- requestString = "method=getQuote&format=text";
- QNetworkRequest request(apiUrl);
- reply = manager.post(request, requestString);
- connect(reply, SIGNAL(finished()),this, SLOT(getReplyFinished()));
- connect(reply, SIGNAL(readyRead()), this, SLOT(readyReadReply()));
- }
- Widget::~Widget()
- {
- delete ui;
- }
- void Widget::readyReadReply()
- {
- QString answer = QString::fromUtf8(reply->readAll());
- ui->textEdit->setText(answer);
- }
- void Widget::getReplyFinished()
- {
- reply->deleteLater();
- }
- void Widget::on_pushButton_clicked()
- {
- QString answer = QString::fromUtf8(reply->readAll());
- ui->textEdit->setText(answer);
- }
Advertisement
Add Comment
Please, Sign In to add comment